Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLÄ£ºý²éѯÓï·¨LIKE


Ö´ÐÐ Êý¾Ý¿â²éѯʱ£¬ÓÐÍêÕû²éѯºÍÄ£ºý²éѯ֮·Ö¡£
Ò»°ãÄ£ºýÓï¾äÈçÏ£º
SELECT ×ֶΠfrom ±í WHERE ij×ֶΠLike Ìõ¼þ
ÆäÖйØÓÚÌõ¼þ£¬SQLÌṩÁËËÄÖÖÆ¥Åäģʽ£º
1£¬%£º±íʾÈÎÒâ0¸ö»ò¶à¸ö×Ö·û¡£¿ÉÆ¥ÅäÈÎÒâÀàÐͺͳ¤¶ÈµÄ×Ö·û£¬ÓÐЩÇé¿öÏÂÈôÊÇÖÐÎÄ£¬ÇëÔËÓÃÁ½¸ö°Ù·ÖºÅ£¨%%£©±íʾ¡£
±ÈÈç SELECT * from [user] WHERE u_name LIKE '%Èý%'
½«»á°Ñu_nameΪ“ÕÅÈý”£¬“ÕÅèÈý”¡¢“Èý½Å蔣¬“ÌÆÈý²Ø”µÈµÈÓГÈý”µÄ¼Ç¼ȫÕÒ³öÀ´¡£
ÁíÍ⣬Èç¹ûÐëÒªÕÒ³öu_nameÖмÈÓГÈý”ÓÖÓГ蔵ļǼ£¬ÇëÔËÓà andÌõ¼þ
SELECT * from [user] WHERE u_name LIKE '%Èý%' AND u_name LIKE '%è%'
ÈôÔËÓà SELECT * from [user] WHERE u_name LIKE '%Èý%è%'
ËäÈ»ÄÜËÑË÷³ö“Èý½Å蔣¬µ«²»ÄÜËÑË÷³ö·ûºÏÌõ¼þµÄ“ÕÅèÈý”¡£
2£¬_£º ±íʾÈÎÒâµ¥¸ö×Ö·û¡£Æ¥Åäµ¥¸öÈÎÒâ×Ö·û£¬Ëü³£ÓÃÀ´ÏÞ¶¨±í´ïʽµÄ×Ö·û³¤¶ÈÓï¾ä£º
±ÈÈç SELECT * from [user] WHERE u_name LIKE '_Èý_'
Ö»ÕÒ³ö“ÌÆÈý²Ø”ÕâÑùu_nameΪÈý¸ö×ÖÇÒÖмäÒ»¸ö×ÖÊÇ“Èý”µÄ£»
ÔÙ±ÈÈç SELECT * from [user] WHERE u_name LIKE 'Èý__';
Ö»ÕÒ³ö“Èý½Åè”ÕâÑùnameΪÈý¸ö×ÖÇÒµÚÒ»¸ö×ÖÊÇ“Èý”µÄ£»
3£¬[ ]£º±íʾÀ¨ºÅÄÚËùÁÐ×Ö·ûÖеÄÒ»¸ö£¨ÀàËÆÕýÔò±í´ïʽ£©¡£Ö¸¶¨Ò»¸ö×Ö·û¡¢×Ö·û´®»ò·¶Î§£¬ÒªÇóËùÆ¥Åä¶ÔÏóΪËüÃÇÖеÄÈÎÒ»¸ö¡£
±ÈÈç SELECT * from [user] WHERE u_name LIKE '[ÕÅÀîÍõ]Èý'
½«ÕÒ³ö“ÕÅÈý”¡¢“ÀîÈý”¡¢“ÍõÈý”£¨¶ø²»ÊÇ“ÕÅÀîÍõÈý”£©£»
Èç [ ] ÄÚÓÐһϵÁÐ×Ö·û£¨01234¡¢abcdeÖ®ÀàµÄ£©Ôò¿ÉÂÔдΪ“0-4”¡¢“a-e”
SELECT * from [user] WHERE u_name LIKE 'ÀÏ[1-9]'
½«ÕÒ³ö“ÀÏ1”¡¢“ÀÏ2”¡¢……¡¢“ÀÏ9”£»
4£¬[^ ] £º±íʾ²»ÔÚÀ¨ºÅËùÁÐÖ®Äڵĵ¥¸ö×Ö·û¡£ÆäÈ¡ÖµºÍ [] Ïàͬ£¬µ«ËüÒªÇóËùÆ¥Åä¶ÔÏóΪָ¶¨×Ö·ûÒÔÍâµÄÈÎÒ»¸ö×Ö·û¡£
±ÈÈç SELECT * from [user] WHERE u_name LIKE '[^ÕÅÀîÍõ]Èý'
½«ÕÒ³ö²»ÐÕ“ÕÅ”¡¢“À¢“Íõ”µÄ“ÕÔÈý”¡¢“ËïÈý”µÈ£»
SELECT * from [user] WHERE u_name LIKE 'ÀÏ[^1-4]';
½«Åųý“ÀÏ1”µ½“ÀÏ4”£¬Ñ°ÕÒ“ÀÏ5&rd


Ïà¹ØÎĵµ£º

Éî¶È¶Ô±ÈOracleÓëSQL Server

Ò»°ãµÄ¹«Ë¾Í¨³£»áÔÚËûÃǵÄÐÅϢϵͳ¼Ü¹¹ÖÐÒýÈë¶àÖÖÊý¾Ý¿âƽ̨£¬Í¬Ê±ÒýÈëÈýµ½ËÄÖÖ²»Í¬µÄRDBMS½â¾ö·½°¸µÄÖдóÐ͹«Ë¾Ò²²¢²»ÉÙ¼û£¬µ±È»ÕâЩ¹«Ë¾ÀïÃæµÄDBAÃÇͨ³£Ò²ÐèҪͬʱӵÓйÜÀí¶àÖÖ²»Í¬Æ½Ì¨µÄ¼¼ÄÜÁË¡£
Ö»ÔÚÒ»ÖÖƽ̨ÉÏÕ¹¿ª¹¤×÷µÄÊý¾Ý¿âר¼ÒÃÇҲͨ³£»áÆÚ´ý×ÅÔÚËûÃǵÄÏÂÒ»·Ý¹¤×÷ÖÐÄÜѧµ½µã²»Ò»ÑùµÄ¶«Î÷£¬ÄÇЩÓÐÓÂÆøµÄÈËÃÇÔòÔ¸Òâ ......

ʱ¼ä²î¼ÆËã: SQL Server DATEDIFF() º¯Êý

SQL Server DATEDIFF() º¯Êý
¶¨ÒåºÍÓ÷¨
DATEDIFF() º¯Êý·µ»ØÁ½¸öÈÕÆÚÖ®¼äµÄÌìÊý¡£
Óï·¨
DATEDIFF(datepart,startdate,enddate)
startdate ºÍ enddate ²ÎÊýÊǺϷ¨µÄÈÕÆÚ±í´ïʽ¡£
datepart ²ÎÊý¿ÉÒÔÊÇÏÂÁеÄÖµ£º
datepartËõд
Äê
yy, yyyy
¼¾¶È
qq, q
ÔÂ
mm, m
ÄêÖеÄÈÕ
dy, y
ÈÕ
dd, d
ÖÜ
wk, ww
ÐÇÆÚ ......

Sql Server 2005Êý¾Ý¿â±»±ê¼ÇΪ¡°¿ÉÒÉ¡±ÎÊÌâ


ÎÊÌâ±³¾°£º
¡¡¡¡ÈÕ³£¶ÔSql Server 2005¹ØϵÊý¾Ý¿â½øÐвÙ×÷ʱ£¬ÓÐʱ¶ÔÊý¾Ý¿â£¨È磺SharepointÍøÕ¾ÅäÖÃÊý¾Ý¿âÃû
Sharepoint_Config£©½øÐÐЩ²»Õý³£²Ù×÷ÈçÊý¾Ý¿âÔÚ¶Áдʱ¶øÎÞ¹ÊÍ£Ö¹Êý¾Ý¿â£¬´Ó¶øµ¼ÖÂSql Server 2005Êý¾Ý¿â²»Õý³£
Öжϣ¬µ±Ôٴδò¿ªÊý¾Ý¿âʱ»á·¢ÏÖijЩÊý¾Ý¿â»á±»±ê¼ÇΪ“¿ÉÒÉ”£¨suspect)£¬¼´ÔÚÊý¾ ......

Java·ÀÖ¹SQL×¢Èë

 SQL×¢ÈëÊÇ×î³£¼ûµÄ¹¥»÷·½Ê½Ö®Ò»,Ëü²»ÊÇÀûÓòÙ×÷ϵͳ»òÆäËüϵͳµÄ©¶´À´ÊµÏÖ¹¥»÷µÄ,¶øÊdzÌÐòÔ±ÒòΪûÓÐ×öºÃÅжÏ,±»²»·¨
Óû§×êÁËSQLµÄ¿Õ×Ó,ÏÂÃæÎÒÃÇÏÈÀ´¿´ÏÂʲôÊÇSQL×¢Èë:
          ±ÈÈçÔÚÒ»¸öµÇ½½çÃæ,ÒªÇóÓû§ÊäÈëÓû§ÃûºÍÃÜÂë:
     & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ