sqlÖÐʲôÊDZäÁ¿Ãû
sql µÄ±äÁ¿ÃûÊÇÃüÃûÄÚ´æÇøÓò£¬ÓÃÓÚ´æ´¢ÔÝʱÊý¾Ý¡£±äÁ¿Ãû±ØÐèÒÔ×Öĸ»òÏ»®Ïß¿ªÍ·£¬Ö»ÄÜ°üÀ¨×Öĸ¡¢Êý×Ö¡¢Ï»®ÏßºÍ $£¬³¤¶ÈÒÀÊý¾Ý¿âÖÎÀíϵͳ¶øÒ졣ͨ¹ýʹÓà declare Óï¾äÉùÃ÷±äÁ¿Ãû£¬²¢ÔÚ sql Óï¾äÖÐʹÓà @ ·ûºÅÒýÓ㬿ÉÒÔ¶¯Ì¬µØ²åÈë????ÐÞ¸ÄÊý¾Ý¡£ÀýÈ磬declare @city varchar(100); set @city = ‘new york’; select * from customers where city = @city; ´ËÅÌÎʻ᷵»ØËùÓж¼»áΪ¡°new york¡±µÄ¿Í»§
SQL ÖеıäÁ¿Ãû
SQL ÖеıäÁ¿ÃûÊÇÓÃÓÚ´æ´¢ÔÝʱÊý¾ÝµÄÃüÃûÄÚ´æÇøÓò¡£ËüÃÇÔÚÈκΠSQL Óï¾äÖж¼¿ÉÒÔÒýÓã¬ÒÔ±ãÔÚÅÌÎÊ»ò²Ù×÷ÖÐʹÓö¯Ì¬Êý¾Ý¡£
±äÁ¿ÃûµÄ¹æÔò£º
±ØÐèÒÔ×Öĸ»òÏ»®Ïß¿ªÍ·¡£
Ö»¿ÉÒÔʹÓÃ×Öĸ¡¢Êý×Ö¡¢Ï»®ÏߺÍÃÀÔª·ûºÅ ($)¡£
²»¿É°üÀ¨¿Õ¸ñ»òÌØÊâ×Ö·û¡£
²»¿É±£´æÒªº¦×Ö»ò SQL º¯ÊýÃû¡£
³¤¶ÈÒò DBMS ¶øÒ죬µ«Í¨³£ÔÚ 30 µ½ 128 ¸ö×Ö·ûÖ®¼ä¡£
ÔõÑùÉùÃ÷±äÁ¿Ãû£º
ʹÓà DECLARE Óï¾äÉùÃ÷±äÁ¿Ãû£¬ºó¸úÆäÊý¾ÝÀàÐÍ£º
DECLARE @variable_name data_type;
µÇ¼ºó¸´ÖÆ
ÀýÈ磺
DECLARE @name VARCHAR(255);
µÇ¼ºó¸´ÖÆ
ÔõÑùʹÓñäÁ¿Ãû£º
ÔÚ SQL Óï¾äÖÐͨ¹ýʹÓà @ ·ûºÅÒýÓñäÁ¿Ãû£º
SELECT * FROM table_name WHERE column_name = @variable_name;
µÇ¼ºó¸´ÖÆ
Ëü¿ÉÒÔ¶¯Ì¬µØ²åÈë»òÐÞ¸ÄÊý¾Ý£¬´Ó¶øÌá¸ßÅÌÎʵÄÎÞаÐÔ¡£
ʾÀý£º
ÏÂÃæÊÇÒ»¸öʹÓñäÁ¿ÃûµÄʾÀýÅÌÎÊ£º
DECLARE @city VARCHAR(100); SET @city = 'New York'; SELECT * FROM customers WHERE city = @city;
µÇ¼ºó¸´ÖÆ
´ËÅÌÎʽ«·µ»ØËùÓж¼»áΪ¡°New York¡±µÄ¿Í»§¼Í¼¡£Í¨¹ýʹÓñäÁ¿Ãû£¬Óû§¿ÉÒÔƾ֤ÐèÒª¶¯Ì¬µØ¸ü¸ÄËÑË÷Ìõ¼þ¡£
ÒÔÉϾÍÊÇsqlÖÐʲôÊDZäÁ¿ÃûµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡