SQL »ù±¾²Ù×÷ ɾ³ý ÐÞ¸Ä Ë¢ÐÂ
SQL³£ÓÃÃüÁîʹÓ÷½·¨£º
(1) Êý¾Ý¼Ç¼ɸѡ£º
sql="select * from Êý¾Ý±í where ×Ö¶ÎÃû=×Ö¶ÎÖµ order by ×Ö¶ÎÃû [desc]"
sql="select * from Êý¾Ý±í where ×Ö¶ÎÃû like '%×Ö¶ÎÖµ%' order by ×Ö¶ÎÃû [desc]"
sql="select top 10 * from Êý¾Ý±í where ×Ö¶ÎÃû order by ×Ö¶ÎÃû [desc]"
sql="select * from Êý¾Ý±í where ×Ö¶ÎÃû in ('Öµ1','Öµ2','Öµ3')"
sql="select * from Êý¾Ý±í where ×Ö¶ÎÃû between Öµ1 and Öµ2"
(2) ¸üÐÂÊý¾Ý¼Ç¼£º
sql="update Êý¾Ý±í set ×Ö¶ÎÃû=×Ö¶ÎÖµ where Ìõ¼þ±í´ïʽ"
sql="update Êý¾Ý±í set ×Ö¶Î1=Öµ1,×Ö¶Î2=Öµ2 …… ×Ö¶În=Öµn where Ìõ¼þ±í´ïʽ"
(3) ɾ³ýÊý¾Ý¼Ç¼£º
sql="delete from Êý¾Ý±í where Ìõ¼þ±í´ïʽ"
sql="delete from Êý¾Ý±í" (½«Êý¾Ý±íËùÓмǼɾ³ý)
(4) Ìí¼ÓÊý¾Ý¼Ç¼£º
sql="insert into Êý¾Ý±í (×Ö¶Î1,×Ö¶Î2,×Ö¶Î3 …) valuess (Öµ1,Öµ2,Öµ3 …)"
sql="insert into Ä¿±êÊý¾Ý±í select * from Ô´Êý¾Ý±í" (°ÑÔ´Êý¾Ý±íµÄ¼Ç¼
Ïà¹ØÎĵµ£º
--SQL½âÃÜctext×Ö¶ÎÄÚÈݺ¯Êý
--exec sp_decrypt 'Ô¼ÊøÃû³Æ'
--exec sp_decrypt 'DF_InsuranceRecord_PeriodUnit'
--exec sp_decrypt '´æ´¢¹ý³ÌÃû³Æ'
--exec sp_decrypt 'sp_SearchPrinting_InsuranceRecord'
--Ö÷ÒªÓÃ;:¶ÁÈ¡systemcommentsÖеÄ×Ö¶ÎÄÚÈÝ¡£°üÀ¨Ô¼Êø,´æ´¢¹ý³ÌµÈµÈ¡£
--ÔÎÄÓ¦¸ÃÀ´×Ôhttp://blog.csdn.net ......
תÔØ×Ô£ºhttp://www.neatstudio.com/index-4.shtml
ÎÄÕÂÀ´×Ô¼Åįhacker,http://hi.baidu.com/isbx/blog/item
/08ef48547ef1ad58574e00bf.html:
µ±Ç°µÄWeb¿ª·¢ÕßÖп϶¨Óв»ÉÙÈËûÓÐ×¢Òâµ½×÷ÕßËùÌáµ½µÄÕâÁ½¸öÎÊÌâµÄ¡£
µÚÒ»¸öÎÊÌâÊÇÕâÑùµÄ£¬MySQLĬÈÏÓÐÒ»¸öÅäÖòÎÊý
max_packet_size£¬Õâ¸ö²ÎÊýÊÇÓÃÓÚÏÞÖÆMySQL¿Í»§¶ËºÍMy ......
1¡¢join
A±íµÄÖ÷¼üÊÇ×÷ΪB±íµÄÍâ¼ü¡£ÔÚ²éѯµÄʱºò£¬¿ÉÒÔͨ¹ý²»Í¬µÄjoin½«AºÍB±íÁ´½ÓÆðÀ´£¬´Ó¶øµÃµ½²»Í¬µÄ²éѯ½á¹û¡£
* JOIN: Èç¹û±íÖÐÓÐÖÁÉÙÒ»¸öÆ¥Å䣬Ôò·µ»ØÐÐ
* INNER JOIN: Èç¹ûÁ½¸ö±íÖÐÓÐÆ¥ÅäµÄ£¬Ôò·µ»ØÐÐ
* LEFT JOIN: ¼´Ê¹ÓÒ±íÖÐûÓÐÆ¥Å䣬Ҳ´Ó×ó± ......
ÉÏ´Î×öÁ˸öÏîÄ¿£¬Éæ¼°µ½Êý¾Ý¿âµÄ»¹ÔºÍ»Ö¸´£¬µ½ÍøÉÏÕÒÁËһϣ¬ÊÇÀûÓÃSQLDMOʵÏֵģ¬Ö»ÒªÌí¼ÓSQLDMOÒýÓþͺÃÁË£¬È»ºóÀûÓÃϱߵÄÀàµÄ·½·¨¾Í¿ÉÒÔʵÏÖÁË¡£
¡¡¡¡ÎÒ°ÑÔ×÷ÕßµÄÀàÀ©³äÁËһϣ¬¿ÉÒÔ×Ô¶¯Ê¶±ðweb.configÀï µÄÊý¾Ý¿âÁ¬½Ó×Ö·û´®£¬¿ÉÒÔͨ¹ý±äÁ¿ÉèÖû¹Ô»Ö¸´µÄÐÅÏ¢¡£
¡¡¡¡ÐèҪעÒâµÄʱ»¹Ô£¬»¹ÔµÄʱºòÎÊÌâ×î´óÁË£¬Óбð ......
SQL like×Ó¾äµÄÁíÒ»ÖÖʵÏÖ·½·¨,ËٶȱÈlike¿ì(ת)
Ò»°ãÀ´ËµÊ¹ÓÃÄ£ºý²éѯ£¬´ó¼Ò¶¼»áÏëµ½LIKE
select * from table where a like '%×Ö·û%'
Èç¹ûÒ»¸öSQLÓï¾äÖÐÓöà¸ö likeÄ£ºý²éѯ£¬²¢ÇҼǼÌõÊýºÜ´ó£¬ÄÇËÙ¶ÈÒ»¶¨»áºÜÂý¡£
ÏÂÃæÁ½ÖÖ·½·¨Ò²¿ÉʵÏÖÄ£ºý²éѯ£º
select * from table where patindex('%×Ö·û%',a)>0 ......