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

SQLÖÐÂß¼­²éѯ´¦ÀíµÄ¸÷¸ö½×¶Î

 ÓйØSQLÖÐÂß¼­²éѯ´¦ÀíµÄ¸÷¸ö½×¶Î£¨×Ô¼º¸ãµÄÀý×Ó£¬²»¶ÔµÄ»¶Ó­Ö¸ÕýŶ£©
SQL²»Í¬ÓÚÆäËûµÄ±à³ÌÓïÑÔµÄ×î´ó×î´óÌØÕ÷ÓÐ3¸ö°É£¬
Ò»¸öÊÇËüÊÇÃæÏò¼¯ºÏµÄ±à³Ì˼Ï룬µÚ¶þ¸öÊÇÈýÖµÂß¼­£¨Õâ¸öºóÃæ»á˵µ½£©£¬»¹ÓÐÒ»¸ö¾ÍÊǽñÌìÖ÷ҪҪ˵µÄ²éѯԪËصÄÂß¼­´¦Àí´ÎÐò¡£
Çë¿´Ò»¸ö»ù±¾²éѯµÄÂß¼­¹ý³Ì£º
(8)  SELECT (9) DISTINCT (11) <TOP_specification> <select_list>
(1)  from <left_table>
(3)    <join_type> JOIN <right_table>
(2)      ON <join_condition>
(4)  WHERE <where_condition>
(5)  GROUP BY <group_by_list>
(6)  WITH {CUBE | ROLLUP}
(7)  HAVING <having_condition>
(10) ORDER BY <order_by_list>
´ó¼Ò¿ÉÒÔ¿´µ½ ÕâÀïµÄÔËÐв½Öè²»ÊÇÏñÒ»°ãµÄ±à³Ì Ò»¾ä¾ä´ÓÉÏÍùÏ ËüÊÇÌø¶¯µÄ ÓлîÁ¦µÄ
ÕâÀïÌáǰ˵Ï ÿһ²½¶¼»á²úÉúÒ»¸öÐéÄâµÄ±í£¨Ò²¿ÉÄÜÊÇÓα꣬ÏÂÃæ»áÌáµ½£©£¬×÷ΪÏÂÒ»¸ö²½ÖèµÄÊäÈë¡£´ó¼Ò×îºó¿´µ½µÄ½á¹ûÆäʵ¾ÍÊÇ×îºóÒ»¸öÐéÄâ±íÁË¡£
ºÃÁË£¬ÏÂÃæÎÒ¿ªÊ¼¾ßÌå²ûÊÍÿ¸ö²½Ö裺
²âÊÔ»·¾³£º
--ÌâÄ¿ÒªÇó£ºÇó³öѧÉú×îµÍ¿ÆÄ¿³É¼¨²»µÍÓÚ90·ÖÇÒÄêÁäÔÚ7ËêÒÔÉϵÄѧÉúÐÕÃû
create table #student(s# int,sname varchar(10),age int)
create table #study (s# int, c# char(1),score int)
insert #student
1,'xiaozhu',10 union all select
2,'xiaomao' ,9union all select
3,'xiaozhe' ,7union all select
4,'xiaophai',8 union all select
5,'xiaoduo',9
insert #study select
1,'A',99 union all select
1,'B',90 union all select
1,'C',99 union all select
2,'A',99 union all select
2,'b',99 union all select
2,'c',98 union all select
3,'A',99 union all select
3,'b',92 union all select
3,'c',91 union all select
3,'d',90 union all select
4,'A',88 union all select
4,'B',96
--SQLÓï¾ä
select top 1 sname,MIN(score) as minsocre
from #student s left outer join #study sc
on s.s#=sc.s#
where age>7
group by sname
having MIN(score)>=90
order by minsocre
/*
sname      minsocre
---------- -----------
xiaozhu    90
*/
(1)£ºÖ´Ðеѿ¨¶û»ý£¨CROSS JOIN £©
´ó¼ÒÕâ


Ïà¹ØÎĵµ£º

×Ô¶¯¶¨Ê±ÖØÆôsql server»ØÊÕÄÚ´æ

¡¡×î½üΪÊý¾Ý¿â·þÎñÆ÷Ôö¼ÓÁËÄڴ棬´ïµ½ÁË×î´óÖ§³ÖµÄ8G£¬Êý¾Ý¿âÓõÄÊÇmssql 2005 £¬Ö®Ç°ÄÚ´æÒ»Ö±ÊÇ4GµÄ£¬²»´æÔÚÄÚ´æ´óºÍ32λ²Ù×÷ϵͳ³åÍ»µÄÊÂÇ飬32λ²Ù×÷ϵͳµ¥½ø³Ì×î´óÖ§³Ö2GµÄÄڴ棬ÕâÑù×ӵĻ°ÄÚ´æ¾Í°×¼ÓÁË£¬Ôõô°ìÄØ?
¡¡¡¡ÍøÉÏËÑË÷Á˺ܶà×ÊÁÏ£¬·¢ÏÖ΢ÈíÌṩÁËÒ»¸öËãÊÇÁÙʱµÄ½â¾ö·½°¸°É£¬Ê¹ÓÃAWEÀ´·ÖÅäÄڴ棬ÕâÑù×Ósqlse ......

SQLÊý¾Ý¿âÉè¼Æ¼¼ÇÉdz̸

Êý¾Ý¿âÉè¼Æ¾­Ñé̸
 
Ò»¸ö³É¹¦µÄ¹ÜÀíϵͳ£¬ÊÇÓÉ£º[50% µÄÒµÎñ + 50% µÄÈí¼þ] Ëù×é³É£¬¶ø 50% µÄ³É¹¦Èí¼þÓÖÓÐ [25% µÄÊý¾Ý¿â + 25% µÄ³ÌÐò] Ëù×é³É£¬Êý¾Ý¿âÉè¼ÆµÄºÃ»µÊÇÒ»¸ö¹Ø¼ü¡£Èç¹û°ÑÆóÒµµÄÊý¾Ý±È×öÉúÃüËù±ØÐèµÄѪҺ£¬ÄÇôÊý¾Ý¿âµÄÉè¼Æ¾ÍÊÇÓ¦ÓÃÖÐ×îÖØÒªµÄÒ»²¿·Ö¡£ÓйØÊý¾Ý¿âÉè¼ÆµÄ²ÄÁϺ¹Å£³ä¶°£¬´óѧѧλ¿Î³ÌÀïÒ²ÓÐ ......

SQLÖÐonÌõ¼þÓëwhereÌõ¼þµÄÇø±ð (having)

 
 
SQLÖÐonÌõ¼þÓëwhereÌõ¼þµÄÇø±ð
      Êý¾Ý¿âÔÚͨ¹ýÁ¬½ÓÁ½ÕÅ»ò¶àÕűíÀ´·µ»Ø¼Ç¼ʱ£¬¶¼»áÉú³ÉÒ»ÕÅÖмäµÄÁÙʱ±í£¬È»ºóÔÙ½«ÕâÕÅÁÙʱ±í·µ»Ø¸øÓû§¡£
     ÔÚʹÓÃleft jionʱ£¬onºÍwhereÌõ¼þµÄÇø±ðÈçÏ£º
1¡¢ onÌõ¼þÊÇÔÚÉú³ÉÁÙʱ±íʱʹÓõÄÌõ¼ ......

SQL ºÍ´æ´¢¹ý³Ì¼¶±ðµÄÊÂÎñ¼°ADO.NET¼¶±ðµÄÊÂÎñ

 Êý¾Ý¿âÊÂÎñÊÇÆäËûÊÂÎñÄ£Ð͵Ļù´¡£¬µ±Ò»¸öÊÂÎñ´´½¨Ê±²»Í¬Êý¾Ý¿âϵͳ¶¼ÓÐ×Ô¼ºµÄ¹æ
Ôò¡£SQL Server ĬÈÏÔÚ×Ô¶¯Ìá½»µÄģʽϹ¤×÷£¬Ã¿¸öÓï¾äÖ´ÐÐÍêºó¶¼»áÁ¢¼´Ìá½»£»Óë´Ë¶ÔÕÕ
µÄÊÇ Oracle ÐèÒªÄã°üº¬Ò»¸öÌá½»Óï¾ä¡£µ«Êǵ±Ò»¸öÓï¾äͨ¹ý OLE  DB Ö´ÐÐʱ£¬ËüÖ´ÐÐÍêºó
Ò»¸öÌá½»¶¯×÷»á±»¸½¼ÓÉÏÈ¥¡£ÀýÈ磺
DECLARE  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ