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

50¸ö³£ÓÃsqlÓï¾ä

50¸ö³£ÓÃsqlÓï¾ä
Student(S#,Sname,Sage,Ssex) ѧÉú±í
Course(C#,Cname,T#) ¿Î³Ì±í
SC(S#,C#,score) ³É¼¨±í
Teacher(T#,Tname) ½Ìʦ±í
ÎÊÌ⣺
1¡¢²éѯ“001”¿Î³Ì±È“002”¿Î³Ì³É¼¨¸ßµÄËùÓÐѧÉúµÄѧºÅ;
  select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
  from SC where C#='002') b
  where a.score>b.score and a.s#=b.s#;
2¡¢²éѯƽ¾ù³É¼¨´óÓÚ60·ÖµÄͬѧµÄѧºÅºÍƽ¾ù³É¼¨;
    select S#,avg(score)
    from sc
    group by S# having avg(score) >60;
3¡¢²éѯËùÓÐͬѧµÄѧºÅ¡¢ÐÕÃû¡¢Ñ¡¿ÎÊý¡¢×ܳɼ¨;
  select Student.S#,Student.Sname,count(SC.C#),sum(score)
  from Student left Outer join SC on Student.S#=SC.S#
  group by Student.S#,Sname
4¡¢²éѯÐÕ“ÀÄÀÏʦµÄ¸öÊý;
  select count(distinct(Tname))
  from Teacher
  where Tname like 'Àî%';
5¡¢²éѯûѧ¹ý“Ҷƽ”ÀÏʦ¿ÎµÄͬѧµÄѧºÅ¡¢ÐÕÃû;
    select Student.S#,Student.Sname
    from Student 
    where S# not in (select distinct( SC.S#) from SC,Course,Teacher where  SC.C#=Course.C# and Teacher.T#=Course.T# and Teacher.Tname='Ҷƽ');
6¡¢²éѯѧ¹ý“001”²¢ÇÒҲѧ¹ý±àºÅ“002”¿Î³ÌµÄͬѧµÄѧºÅ¡¢ÐÕÃû;
  select Student.S#,Student.Sname from Student,SC where Student.S#=SC.S# and SC.C#='001'and exists( Select * from SC as SC_2 where SC_2.S#=SC.S# and SC_2.C#='002');
7¡¢²éѯѧ¹ý“Ҷƽ”ÀÏʦËù½ÌµÄËùÓпεÄͬѧµÄѧºÅ¡¢ÐÕÃû;
  select S#,Sname
  from Student
  where S# in (select S# from SC ,Course ,Teacher where SC.C#=Course.C# and Teacher.T#=Course.T# and Teacher.Tname='Ҷƽ' group by S# having count(SC.C#)=(select count(C#) from Course,Teacher  where Teacher.T#=Course.T# and Tname='Ҷƽ'));
8¡¢²éѯ¿Î³Ì±àºÅ“002”µÄ³É¼¨±È¿Î³Ì±àºÅ“001”¿Î³ÌµÍµÄËùÓÐͬѧµÄѧºÅ¡¢ÐÕÃû;
  Select S#,Sname from (select Student.S#,Stud


Ïà¹ØÎĵµ£º

SQL Server Óï¾ä

1.SELECTÓï¾ä´ÓÊý¾Ý¿âÖÐѡȡÊý¾Ý
SELECT 'ÁÐÃû' from '±íÃû' SELECT list_name from table_name ´Ó '±íÃû' Ñ¡Çø'ÁÐÃû' Êý¾Ý SQL SELECT * from table_name ´Ó '±íÃû' Ñ¡ÇøÈ«²¿Êý¾Ý
2.SELECT ¼ÓWHERE Óï¾ä
SELECT 'ÁÐÃû' from '±íÃû' WHERE 'Ìõ¼þ'
3.SELECT ¼ÓAS Óï¾ä
ʹÓÃAS ¸øÊý¾ÝÖ¸¶¨Ò»¸ö±ðÃû¡£´Ë±ðÃûÓÃÀ´ÔÚ±í´ïʽ ......

SQLÓï¾äÓÅ»¯

¶ÔͬһÕÅ±í½øÐÐÁ½ÖÖ·½Ê½²éѯ£¨½á¹û¼¯Ïàͬ£©£º
case1 ²éѯÌõ¼þ:°üÀ¨¼ÆËã»úÃû£¬êdzƣ¬Ìí¼Óʱ¼äµÈµÈһЩÏÞÖÆÌõ¼þ×ֶΡ£¶øÇÒÐèÁª±í²éѯ±ðµÄ±í
²éѯÊý¾ÝÁ¿£º             100Íò       200Íò
µ¥´¿Ö´ÐÐSQLÓï¾äËùÐèʱ¼ä£º31ºÁÃë&nbs ......

ͻȻÏëÓÃSQLÓï¾äÀ´½øÐÐMD5¼ÓÃÜ~~

×î½üÔÚ×öÒ»¸ö×¢²á³ÌÐò£¬µÃÓõÃÃÜÂëµÄMD5¼ÓÃÜ£¬Ö±½ÓÔÚ´æ´¢¹ý³ÌÖнøÐÐ×¢²á¡£
²éÕҵõ½£¬¿ÉÓÃÒÔÏ·½·¨½øÐмÓÃÜ£º
print RIGHT(sys.fn_VarBinToHexStr(hashbytes('MD5','ANSEN')),32)
Êý¾Ý¿âÊÇÓÃSQL SERVER 2005£¬ÆäËûµÄÊý¾Ý¿âÓ¦¸ÃÒ²²î²»µ½ÄÄÈ¥~~ ......

sqlÖÐÊý¾Ý¿â»Ø¹öµÄ²Ù×÷Ïê½â1

À´×Ôhttp://hi.baidu.com/zcy60156/blog/item/42b6c5802a33859af603a685.html
ÍÆ¼öÊÇÓô洢¹ý³Ì¼ÓÊÂÎñʵÏÖ.»òÖ±½ÓÔÚaspÀïд¼ÓÉÏÊÂÎñ¾Í¿ÉÒÔͬʱµÄ²åÈëÁË.Èç¹ûÖмä³ö´íµÄ»°»¹Äܻعö,¿É±£³ÖÊý¾ÝµÄÒ»ÖÂÐÔ.È¥baiduÉÏËÑË÷Ò»ÏÂÊÂÎñµÈµÄÏà¹Ø×ÊÁϺܶàµÄ.
ÔÚ¿ª·¢WebÓ¦ÓÃʱ£¬ÎÞÒ»ÀýÍâµØÐèÒª·ÃÎÊÊý¾Ý¿â£¬ÒÔÍê³É¶ÔÊý¾ÝµÄ²éѯ¡¢²åÈë¡¢¸ ......

MFCÖÐÓÃado·ÃÎÊSQL Server 2005Êý¾Ý¿â

MFCÖÐÓÃado·ÃÎÊSQL Server 2005Êý¾Ý¿â
½ñÌìÀÏ´ó½»´úÏîÄ¿£¬ÐèÒªMFC·ÃÎÊÁíһ̨»úÆ÷É쵀 SQL Server 2005Êý¾Ý¿â¡£MFCÎÒ²»Ê죬SQLÒ²´ÓûÓùý¡£ÔÚÍøÉϲéÁ˲»ÉÙ×ÊÁÏ£¬Ã¦ÁËÒ»ÕóÖÕÓÚ¸ãͨÁË¡£Óë¸÷λÅóÓÑ·ÖÏíһϣ¬¸ßÊÖÃǾͲ»Óÿ´ÁË£¬ÕâÊÇд¸øÏñÎÒÒ»Ñù³õѧÕߵġ£
Ò»¡¢°²×°SQL SERVER 2005£¬ÔÚ±¾»ú½¨Á¢·þÎñÆ÷ĬÈϰ²×°¼´¿É£¬Ò²¿ÉÒÔ×Ô¼ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ