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

SQLÄ£ºý²éѯ

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”¡¢“ÀÏ6”¡¢……
5£¬²éѯÄÚÈÝ°üº¬Í¨Åä·ûʱ
ÓÉÓÚͨÅä·ûµÄÔµ¹Ê£¬µ¼ÖÂÎÒÃDzéѯÌØÊâ×Ö·û“%”¡¢“_”¡¢“[&r


Ïà¹ØÎĵµ£º

50ÖÖ·½·¨ÇÉÃîÓÅ»¯ÄãµÄSQL ServerÊý¾Ý¿â

Ô­ÎÄÁ´½Ó:http://blog.btidea.com/article.asp?id=440
²éѯËÙ¶ÈÂýµÄÔ­ÒòºÜ¶à£¬³£¼ûÈçϼ¸ÖÖ£º
¡¡¡¡
¡¡¡¡1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
¡¡¡¡
¡¡¡¡2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
¡¡¡¡
¡¡¡¡3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£
¡¡¡¡
¡¡¡¡4¡¢ÄÚ´æ²»×ã
¡¡¡¡
¡¡¡¡5¡¢ÍøÂç ......

SQLÓÅ»¯ Ë÷Òý

(Ò»)ÉîÈëdz³öÀí½âË÷Òý½á¹¹
¡¡¡¡Êµ¼ÊÉÏ£¬Äú¿ÉÒÔ°ÑË÷ÒýÀí½âΪһÖÖÌØÊâµÄĿ¼¡£Î¢ÈíµÄSQL SERVERÌṩÁËÁ½ÖÖË÷Òý£º¾Û¼¯Ë÷Òý(clustered index£¬Ò²³Æ¾ÛÀàË÷Òý¡¢´Ø¼¯Ë÷Òý)ºÍ·Ç¾Û¼¯Ë÷Òý(nonclustered index£¬Ò²³Æ·Ç¾ÛÀàË÷Òý¡¢·Ç´Ø¼¯Ë÷Òý)¡£ÏÂÃ棬ÎÒÃǾÙÀýÀ´ËµÃ÷һϾۼ¯Ë÷ÒýºÍ·Ç¾Û¼¯Ë÷ÒýµÄÇø±ð£º
¡¡¡¡Æäʵ£¬ÎÒÃǵĺºÓï×ÖµäµÄÕýÎı ......

SQL ÓαêÔ­ÀíºÍʹÓ÷½·¨

 Êý¾Ý¿â¿ª·¢¹ý³ÌÖУ¬µ±Äã¼ìË÷µÄÊý¾ÝÖ»ÊÇÒ»Ìõ¼Ç¼ʱ£¬ÄãËù±àдµÄÊÂÎñÓï¾ä´úÂëÍùÍùʹÓÃSELECT INSERT Óï¾ä¡£µ«ÊÇÎÒÃdz£³£»áÓöµ½ÕâÑùÇé¿ö£¬¼´´Óijһ½á¹û¼¯ÖÐÖðÒ»µØ¶ÁÈ¡Ò»Ìõ¼Ç¼¡£ÄÇôÈçºÎ½â¾öÕâÖÖÎÊÌâÄØ£¿ÓαêΪÎÒÃÇÌṩÁËÒ»ÖÖ¼«ÎªÓÅÐãµÄ½â¾ö·½°¸¡£
      1.1 ÓαêºÍÓαêµÄÓŵã
  & ......

¾«µäSQLÓï¾ä

·ÖÀàͳ¼Æ×ÜÊý²¢ÅÅÐò¶à±íÁªºÏ²éѯµÄÁ½ÖÖ·½·¨
Àý:
²éѯµØÇø±íÖи÷Ê¡ÏÂÃæ³ÇÊÐ×ÜÊý,²¢¶Ô²éѯ½á¹ûÈ¡Ç°Ê®Ãû
·¨Ò»:
select b.id,a.[name],b.counts from n_area a,(select top 10 parent_id as id,sum(parent_id) as counts from n_area where parent_id<>0 group by parent_id order by sum(parent_id) desc
) b where ......

SQL Server 2008 r2 °²×°¹ý³Ì¼Ç¼

×òÍí£¬µ½Î¢Èí¹Ù·½ÏÂÁËÒ»¸ö32°æ±¾µÄTrial°æ±¾¡£ÎļþÃûΪSQLFULL_x86_ENU.exe¡£Îļþ´óСΪ1.30G×óÓÒ¡£ÒòΪֻÓÐ32λһ¸ö°æ
±¾£¬±ÈSQL Server  2008ÄǸö3GµÄҪС¶àÁË¡£ºÇºÇ¡£
http://www.microsoft.com/sqlserver/2008/en/us/R2Downloads.aspx 
ÏÂ
ÔØÍê³Éºó£¬ÏÈжÔØÔ­À´µÄSQL Server 2008¡¡sp2,½á¹ûÕûÕûÔËÐÐÁËÁ½¸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ