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

sqlÓï¾äÖеÄ[]


¼Ó[ ]ÓÃÓÚ¶¨½çÁÐÃû»ò±íÃûµÈÐÅÏ¢£¬ÒÔÇø±ðһЩÌØÊâµÄ²»ºÏÃüÃû¹æÔòµÄ×Ö´®£¬»òÊÇÓëϵͳ±£Áô×ÖÓгåÍ»¡£
Èç"user"ÊÇSQL Server±£ÁôµÄ¹Ø¼ü×Ö£¬ËùÒÔÓÃ"select * from user"²éѯ»áÌáʾÓï·¨´íÎó¡£¼ÓÉÏÖÐÀ¨ºÅ£¬ÒÔÉùÃ÷Æä²»ÊDZ£Áô×Ö¡£
"select * from [user]"
Èç¹û±íÃû²»Êǹؼü×Ö£¬ÈçCompany£¬ÔòÓÃ"select * from Company"ÊÇûÎÊÌâµÄ£¬²»ÓüÓÖÐÀ¨ºÅ,µ±È»×îºÃµÄ°ì·¨ÊDZíÃûͳͳ¼Ó·½À¨ºÅ
[] ÀïµÄÄÚÈݱíʾÊÇÒ»¸öÓû§¼¶µÄ±äÁ¿.
Ä¿µÄÊÇ·ÀÖ¹Óû§Ê¹ÓõÄÃû³ÆºÍϵͳ±£Áô×Ö³åÍ»
±ÈÈçÄãÓÐÒ»¸ö±íÃû¾Í½Ðselect
ÄÇôÄã select * from select¿Ï¶¨ÊDz»ÐеÄ.
µ«ÊÇÄãselect * from [select] ¾ÍûÎÊÌâÁË
ÄãÄǸö userÒ²ÊÇÒ»Ñù.
ËùÓеıíÃû×Ö¶ÎÃû¶¼¿ÉÒÔ¼Ó[],µ«ÊÇÖ»Òª²»¸úϵͳ¹Ø¼ü×Ö³åÍ»¾Í¿ÉÒÔÊ¡ÂÔ


Ïà¹ØÎĵµ£º

SQL ²éѯÓï¾äʹÓÃ

Ò»¡¢¼òµ¥²éѯ
¡¡¡¡ ¼òµ¥µÄTransact-SQL²éѯֻ°üÀ¨Ñ¡ÔñÁÐ±í¡¢from×Ó¾äºÍWHERE×Ӿ䡣
ËüÃÇ·Ö±ð˵Ã÷Ëù²éѯÁС¢²éѯµÄ
±í»òÊÓͼ¡¢ÒÔ¼°ËÑË÷Ìõ¼þµÈ¡£
ÀýÈ磬ÏÂÃæµÄÓï¾ä²éѯtesttable±íÖÐÐÕÃûΪ“ÕÅÈý”µÄnickname×ֶκÍemail×ֶΡ£
SELECT nickname,email
from testtable WHERE name='ÕÅÈý'
(Ò»)Ñ¡ÔñÁбí
¡ ......

SQL Ìõ¼þÓï¾ä

µÚÒ»ÖÖ£º
SELECT
CASE

     WHEN
price IS NULL THEN
'Not yet priced'
     WHEN
price < 10 THEN
'Very Reasonable Title'
     WHEN
price >= 10 AND
price < 20 THEN
'Coffee Table Title'
     EL ......

¹ØÓÚ·ÖÒ³µÄsqlÓï¾ä

¶ÔÓÚÓÐÖ÷¼ü×Ô¶¯Ôö³¤Êý¾Ý¿â±í£¬ÔÚ½øÐзÖÒ³ÉèÖÃʱ£¬ÎÒÈÏΪ»¹±È½Ï²»´íµÄÊÇ£º
SELECT TOP Ò³´óС *
from TestTable
WHERE (ID >
          (SELECT MAX(id)
         from (SELECT TOP Ò³´óС*Ò³Êý id
     ......

Sqlʱ¼äº¯Êý

Sqlʱ¼äº¯Êý
Ò»¡¢sql serverÈÕÆÚʱ¼äº¯Êý
Sql ServerÖеÄÈÕÆÚÓëʱ¼äº¯Êý 
1.  µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä 
    select getdate()  
2. dateadd  ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØеĠdatetime Öµ
   Àý ......

¡¾×ª¡¿ sqlͳ¼Æ£­¹ØÓÚѧÉú³É¼¨(´ð°¸)

sqlͳ¼Æ£­¹ØÓÚѧÉú³É¼¨(´ð°¸)
http://blog.sina.com.cn/s/blog_61380b320100ej9p.html
´ð°¸£º
1.       ¼ÆËãÿ¸öÈ˵Ä×ܳɼ¨²¢ÅÅÃû
select name,sum(score) as allscore from stuscore group by name order by allscore
2. &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ