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#,Student.Snam
Ïà¹ØÎĵµ£º
1.update a set a.nickname=b.nickname from tab1 a,tab2 b where a.username=b.username
2.Update student_score set
student_score.level=level_about.level from
level_about where student.score
between level_about.start_score and level_about.end_score ......
ÔÚSQL UPDATEÓï¾äÖУ¬¶Ô»»Á½¸ö±äÁ¿µÄÖµ£¬²»ÐèÒªÁÙʱ±äÁ¿¡£=ÓÒ²àµÄÖµÔÚÕû¸öUPDATEÓï¾äÖж¼ÊÇÒ»Öµģ»ËùÓеĸüÐÂͬʱ·¢Éú£¬¶ø²»ÊÇÒ»¸ö½Ó×ÅÒ»¸ö·¢Éú¡£
ÀýÈ磺
UPDATE offenceTeam
SET goalShooter=wingAttack,
& ......
ËäȻ˵ASP.NETÊôÓÚ°²È«ÐԸߵĽű¾ÓïÑÔ,µ«ÊÇÒ²¾³£¿´µ½ASP.NETÍøÕ¾ÓÉÓÚ¹ýÂ˲»ÑÏÔì³É×¢Éä.ÓÉÓÚASP.NET»ù±¾ÉÏÅäºÏMMSQLÊý¾Ý¿â¼ÜÉè Èç¹ûȨÏÞ¹ý´óµÄ»°ºÜÈÝÒ×±»¹¥»÷. ÔÙÕßÔÚÍøÂçÉÏÕÒ²»µ½ºÃµÄASP.NET·À×¢Éä½Å±¾,ËùÒÔ¾Í×Ô¼ºÐ´Á˸ö. ÔÚÕâÀï¹²Ïí³öÀ´Ö¼ÔÚÈóÌÐòÔ±Ãâ³ýSQL×¢ÈëµÄÀ§ÈÅ.
ÎÒдÁËÁ½¸ö°æ±¾,VB.NETºÍC#°æ±¾·½±ã²»Í¬³ÌÐò¼äʹÓà ......
SqlÓï¾ä
1. ˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ£¬Ô´±íÃû£ºa£¬Ð±íÃû£ºb) SQL:select * into bfrom awhere 1<>1;
2. ˵Ã÷£º¿½±´± ......
SQL> setsqlprompt"_user _privilege> " ͨ¹ýÒÔÉÏÉèÖã¬ÄãµÄsqlplusÌáʾ±êʶ¾Í³ÉÁËÒÔϸñʽÁË£º SYS AS SYSDBA> Õâ¾Í±íÃ÷µ±Ç°µÄµÇ¼ÕʺÅÊÇSYS£¬Éí·ÝÊÇSYSDBA¡£Çë×¢ÒâÔÚÉÏÃæÓï¾äÖÐʹÓÃÁËÁ½¸öÌØÊâµÄÔ¤¶¨ÒåµÀµÂ±äÁ¿£º_userºÍ_privilege£¬·Ö±ð¶¨ÒåÁ˵±Ç°Óû§ºÍÕâ¸öÓû§µÄµÇ¼Éí·Ý£¨È¨ÏÞ£©¡£ÏÖÔÚÎÒÃÇÔÙÔö¼ ......