Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Óï¾ä

·ÖÀàͳ¼Æ×ÜÊý²¢ÅÅÐò¶à±íÁªºÏ²éѯµÄÁ½ÖÖ·½·¨
Àý:
²éѯµØÇø±íÖи÷Ê¡ÏÂÃæ³ÇÊÐ×ÜÊý,²¢¶Ô²éѯ½á¹ûÈ¡Ç°Ê®Ãû
·¨Ò»:
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´æ´¢

declare @p int
declare @p1 int
declare @count int
set @p=0
set @p1=10
set @count=2
if(@count<>0 or @count<>1)
set @p=@p1*@count-10
SELECT [t1].[userid], [t1].[username], [t1].[userorder]
from (
    SELECT ROW_NUMBER() OVER (ORDER BY [t0].[userorder]) AS [ROW_NU ......

¾­µäSQLÓï¾ä

asc °´ÉýÐòÅÅÁÐ
desc °´½µÐòÅÅÁÐ
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý ......

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ºÅ