×ðÁú¿­Ê±

sqlÖÐ$ÊÇʲôÒâ˼

sql ÖÐ $ ·ûºÅÌåÏÖ²ÎÊýռλ·û £¬Ëü±»Ì滻ΪÅÌÎÊÖÐҪʹÓõÄÏÖʵֵ¡£$ ·ûºÅ¿ÉÌá¸ßÅÌÎʵĿɶÁÐÔ¡¢¿ÉÖØÓÃÐÔºÍÇå¾²ÐÔ¡£

SQL ÖÐ $ µÄ¼ÄÒå

ÔÚ SQL ÖÐ £¬$ ·ûºÅÖ¸µÄÊÇÒ»¸ö²ÎÊýռλ·û £¬ËüÌåÏÖÅÌÎÊÖÐÒªÌ滻ΪÏÖʵֵµÄ±äÁ¿¡£

ÔõÑùʹÓà $

ʹÓà $ ·ûºÅÓÐÁ½ÖÖ·½·¨£º

ÃüÃû²ÎÊý£º ʹÓà $parameter_name Óï·¨ £¬ÆäÖÐ parameter_name ÊÇÄúҪʹÓõIJÎÊýµÄÃû³Æ¡£ÀýÈ磺

SELECT * FROM table_name WHERE id = $id;

µÇ¼ºó¸´ÖÆ

λÖòÎÊý£º ʹÓà $1¡¢$2 µÈÓï·¨ £¬ÆäÖÐÊý×ÖÌåÏÖ²ÎÊýÔÚÅÌÎÊÖзºÆðµÄ˳Ðò¡£ÀýÈ磺

SELECT * FROM table_name WHERE id = $1 AND name = $2;

µÇ¼ºó¸´ÖÆ

Óŵã

ʹÓà $ ·ûºÅÓÐÒÔÏÂÓŵ㣺

¿É¶ÁÐÔ£ºËüʹÅÌÎʸüÒ×ÓÚÔĶÁºÍÃ÷È· £¬ÓÉÓÚ²ÎÊýÃû³Æ»òλÖÃÊÇÃ÷È·µÄ¡£

¿ÉÖØÓÃÐÔ£ºÊ¹ÓÃÃüÃû²ÎÊý £¬Äú¿ÉÒÔÖØÓÃÅÌÎʶø²»±Ø¸ü¸ÄÏÖʵֵ¡£

Çå¾²ÐÔ£ºËüÓÐÖúÓÚ±ÜÃâ SQL ×¢Èë¹¥»÷ £¬ÓÉÓÚ²ÎÊýÖµ±»ÊÓΪÊý¾Ý¶ø²»ÊÇ´úÂë¡£

ʾÀý

ÒÔÏÂʾÀýÑÝʾÔõÑùʹÓà $ ·ûºÅ£º

-- ʹÓÃÃüÃû²ÎÊý
SELECT * FROM users WHERE username = $username;

-- ʹÓÃλÖòÎÊý
SELECT * FROM products WHERE price > $1;

µÇ¼ºó¸´ÖÆ

ÔÚÕâЩʾÀýÖÐ £¬$username ºÍ $1 ÊDzÎÊýռλ·û £¬ÔÚÖ´ÐÐÅÌÎÊ֮ǰ±ØÐèÓÃÏÖʵֵÌæ»»ËüÃÇ¡£

ÒÔÉϾÍÊÇsqlÖÐ$ÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿