SQL LIKE ͨÅä·ûËæ±Ê £¨SqlServer£©
ͨÅä·û ˵Ã÷
_ ÓëÈÎÒâµ¥×Ö·ûÆ¥Åä
% Óë°üº¬Ò»¸ö»ò¶à¸ö×Ö·ûµÄ×Ö·û´®Æ¥Åä
[ ] ÓëÌض¨·¶Î§£¨ÀýÈ磬[a-f]£©»òÌض¨¼¯£¨ÀýÈ磬[abcdef]£©ÖеÄÈÎÒâµ¥×Ö·ûÆ¥Åä¡£
[^] ÓëÌض¨·¶Î§£¨ÀýÈ磬[^a-f]£©»òÌض¨¼¯£¨ÀýÈ磬[^abcdef]£©Ö®ÍâµÄÈÎÒâµ¥×Ö·ûÆ¥Åä¡£
Àý×Ó:
• WHERE FirstName LIKE '_im' ¿ÉÒÔÕÒµ½ËùÓÐÈý¸ö×ÖĸµÄ¡¢ÒÔ im ½áβµÄÃû×Ö£¨ÀýÈ磬Jim¡¢Tim£©¡£
• WHERE LastName LIKE '%stein' ¿ÉÒÔÕÒµ½ÐÕÒÔ stein ½áβµÄËùÓÐÔ±¹¤¡£
• WHERE LastName LIKE '%stein%' ¿ÉÒÔÕÒµ½ÐÕÖÐÈÎÒâλÖðüÀ¨ stein µÄËùÓÐÔ±¹¤¡£
• WHERE FirstName LIKE '[JT]im' ¿ÉÒÔÕÒµ½Èý¸ö×ÖĸµÄ¡¢ÒÔ im ½áβ²¢ÒÔ J »ò T ¿ªÊ¼µÄÃû×Ö£¨¼´½öÓÐ Jim ºÍ Tim£©
• WHERE LastName LIKE 'm[^c]%' ¿ÉÒÔÕÒµ½ÒÔ m ¿ªÊ¼µÄ¡¢ºóÃæµÄ£¨µÚ¶þ¸ö£©×Öĸ²»Îª c µÄËùÓÐÐÕ¡£
Ïà¹ØÎĵµ£º
ÔÚÎÒÃǽøÐÐsql×¢ÈëµÄ¹ý³ÌÖг£³£»áÓõ½union²éѯ·½·¨£¬´ó¶àÊýÇé¿öÏÂʹÓÃunion²éѯ·¨¿ÉÒÔÈÃÎÒÃǺܿìµÄÖªµÀÄ¿±êµÄÊý¾Ý×éÖ¯·½Ê½¡£È»¶øµ±ÎÒÃÇÓöµ½ntext¡¢text»òimageÊý¾ÝÀàÐÍʱ£¬union²éѯ¾Í²»Ì«¹ÜÓÃÁË¡£ÒÔsql serverΪÀý£¬ÔÚÕâÖÖÇé¿öÏ»áÅ׳öÈçÏ´íÎó£ºntext Êý¾ÝÀàÐͲ»ÄÜѡΪ DISTINCT£¬ÒòΪËü ......
select * from orders where month(orderdate)= (select month(orderdate) from orders where orderid=10248)
1.Ò»¸öÔµÚÒ»ÌìµÄ
Select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)
2.±¾ÖܵÄÐÇÆÚÒ»
Select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
3.Ò»ÄêµÄµÚÒ»Ìì
Select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)
......
Update Channel set Unit ='mg' ,
RunUpThreshold='10' ,
RunDownThreshold='10' ,
SafetyUpThreshold='10' ,
SafetyDownThreshold='10'
where Bridge='001' and DeviceCode='AS'
and SensorCode='001' and Supplement='N'
set £º ','
where: and ......
Join²Ù×÷·û
ÊÊÓó¡¾°£ºÔÚÎÒÃDZí¹ØϵÖÐÓÐÒ»¶ÔÒ»¹Øϵ£¬Ò»¶Ô¶à¹Øϵ£¬¶à¶Ô¶à¹ØϵµÈ¡£¶Ô¸÷¸ö±íÖ®¼äµÄ¹Øϵ£¬¾ÍÓÃÕâЩʵÏÖ¶Ô¶à¸ö±íµÄ²Ù×÷¡£
˵Ã÷£ºÔÚJoin²Ù×÷ÖУ¬·Ö±ðΪJoin(Join²éѯ), SelectMany(SelectÒ»¶Ô¶àÑ¡Ôñ)ºÍGroupJoin(·Ö×éJoin²éѯ)¡£
¸ÃÀ©Õ¹·½·¨¶ÔÁ½¸öÐòÁÐÖмüÆ¥ÅäµÄÔªËؽøÐÐinner join²Ù×÷
SelectMany
˵Ã÷£ºÎÒà ......