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

SQLÏ°Ìâ2

 µÚʮһÌ⣺
Óбístudents(name,class,grade),ÇëÓñê×¼sqlÓï¾äÍê³É
name class grade
ÕÅÈý Êýѧ 81
ÀîËÄ ÓïÎÄ 70
ÍõÎå Êýѧ 90
ÕÅÈý ÓïÎÄ 60
ÀîËÄ Êýѧ 100
ÍõÎå ÓïÎÄ 90
ÍõÎå Ó¢Óï 81
ÒªÇó: ÓÃsqlÓï¾äÊä³ö¸÷ÃŹ¦¿Î¶¼´óÓÚ80·ÖµÄͬѧÐÕÃû?
create table students (
name varchar(25),
class varchar(25),
grade int
)
insert into students values ('ÕÅÈý','ÓïÎÄ',20)
insert into students values ('ÕÅÈý','Êýѧ',90)
insert into students values ('ÕÅÈý','Ó¢Óï',50)
insert into students values ('ÀîËÄ','ÓïÎÄ',81)
insert into students values ('ÀîËÄ','Êýѧ',60)
insert into students values ('ÀîËÄ','Ó¢Óï',90)
insert into students values ('Íõ¶þ','Êýѧ',81)
insert into students values ('Íõ¶þ','Ó¢Óï',90)
insert into students values ('ÀîÎå','Êýѧ',83)
insert into students values ('ÀîÎå','Ó¢Óï',90)
insert into students values ('ÀîÎå','»¯Ñ§',90)
---Ñ¡³öËùÓгɼ¨´óÓÚ80·ÖµÄѧÉúÐÕÃû-----
------½â·¨Ò»------
select name from students group by name having min(grade)>80
------½â·¨¶þ------
select distinct Name from students where grade >80 and Name not in (select Name from students where grade <80)
------½â·¨Èý------
select distinct name from students where name not in (select name from students where grade <=80 group by name )
-----½â·¨ËÄ-------
select name from students group by name having name not in (select name from students where grade<=80)
µÚÊ®¶þÌ⣺
ÒÑÖªÒ»¸ö±íµÄ½á¹¹Îª£º
ÐÕÃû ¿ÆÄ¿ ³É¼¨
ÕÅÈý ÓïÎÄ 20
ÕÅÈý Êýѧ 30
ÕÅÈý Ó¢Óï 50
ÀîËÄ ÓïÎÄ 70
ÀîËÄ Êýѧ 60
ÀîËÄ Ó¢Óï 90
ÔõÑùͨ¹ýselectÓï¾ä°ÑËû±ä³ÉÒÔϽṹ£º
ÐÕÃû ÓïÎÄ Êýѧ Ó¢Óï
ÕÅÈý 20 30 50
ÀîËÄ 70 60 90
create table students (
name varchar(25),
class varchar(25),
grade int
)
insert into students values ('ÕÅÈý','ÓïÎÄ',20)
insert into students values ('ÕÅÈý','Êýѧ',90)
insert into students values ('ÕÅÈý','Ó¢Óï',50)
insert into students values ('ÀîËÄ','ÓïÎÄ',81)
insert into students values ('ÀîËÄ','Êýѧ',60)
insert into students values ('ÀîËÄ','Ó¢Óï',90)
--½â´ð£º
select A.Name,A.grade as ÓïÎÄ,


Ïà¹ØÎĵµ£º

ÈçºÎµ¼Èë.sqlÎļþµ½mysqlÖÐ

ÈçºÎµ¼Èë.sqlÎļþµ½mysqlÖУ¿
C:\mysql\bin>mysql  -u  Óû§Ãû -p  Êý¾Ý¿âÃû  <   c:/test.sql    (source "c:\adsense.sql" )
ÖмäµÄ¿Õ¸ñÊÇÒ»¸ö¿Õ¸ñλ¡£
ͬʱʹÓÃ200¶àMBµÄsqlÎļþ¡£
ÀýÈ磺
C:\Program Files\MySQL\bin>mysql -u root -p myrosz & ......

SQL×¢Èë·¨¹¥»÷Ò»ÈÕͨ

 
Ëæ×ÅB/SģʽӦÓÿª·¢µÄ·¢Õ¹£¬Ê¹ÓÃÕâÖÖģʽ±àдӦÓóÌÐòµÄ³ÌÐòÔ±Ò²Ô½À´Ô½¶à¡£µ«ÊÇÓÉÓÚ³ÌÐòÔ±µÄˮƽ¼°¾­ÑéÒ²²Î²î²»Æ룬Ï൱´óÒ»²¿·Ö³ÌÐòÔ±ÔÚ±àд´úÂëµÄʱºò£¬Ã»ÓжÔÓû§ÊäÈëÊý¾ÝµÄºÏ·¨ÐÔ½øÐÐÅжϣ¬Ê¹Ó¦ÓóÌÐò´æÔÚ°²È«Òþ»¼¡£Óû§¿ÉÒÔÌá½»Ò»¶ÎÊý¾Ý¿â²éѯ´úÂ룬¸ù
¾Ý³ÌÐò·µ»ØµÄ½á¹û£¬»ñµÃijЩËûÏëµÃÖªµÄÊý¾Ý£¬Õâ¾ÍÊÇËù ......

²é³öË­µÄ½±½ð×ܺÏÊÇ×î¸ßµÄ£¬SQLÓï¾ä

 Ô­ÎÄ´«ËÍÃÅ£ºhttp://topic.csdn.net/u/20091119/17/388cd1dd-4018-403f-a97f-0bc135895264.html?85256
Êý¾Ý¿âÀýÈç:
id      ÐÕ  Ãû  ½±  ½ð
1        ÕÅÈý    20Íò
2        ÀîËÄ    10Íò
3      ......

SQLÖÐDATEADDºÍDATEDIFFµÄÓ÷¨

 Í¨³££¬ÄãÐèÒª»ñµÃµ±Ç°ÈÕÆںͼÆËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬ÄãµÄ³ÌÐò¿ÉÄÜÐèÒªÅжÏÒ»¸öÔµĵÚÒ»Ìì»òÕß×îºóÒ»Ìì¡£ÄãÃǴ󲿷ÖÈË´ó¸Å¶¼ÖªµÀÔõÑù°ÑÈÕÆÚ½øÐзָÄê¡¢Ô¡¢Èյȣ©£¬È»ºó½ö½öÓ÷ָî³öÀ´µÄÄê¡¢Ô¡¢ÈյȷÅÔÚ¼¸¸öº¯ÊýÖмÆËã³ö×Ô¼ºËùÐèÒªµÄÈÕÆÚ£¡
:B;wr N$EEx)[ aL0
ÔÚÕâƪÎÄÕÂÀÎÒ½«¸æËßÄãÈçºÎʹÓÃDATEADDºÍ ......

sql×Ö·û´®Ä£Ê½Æ¥Åä

 MySQLÌṩ±ê×¼µÄSQLģʽƥÅ䣬ÒÔ¼°Ò»ÖÖ»ùÓÚÏóUnixʵÓóÌÐòÈçvi¡¢grepºÍsedµÄÀ©Õ¹ÕýÔò±í´ïʽģʽƥÅäµÄ¸ñʽ¡£ ±ê×¼µÄSQLģʽƥÅä
SQLµÄģʽƥÅäÔÊÐíÄãʹÓÓ_”Æ¥ÅäÈκε¥¸ö×Ö·û£¬¶ø“%”Æ¥ÅäÈÎÒâÊýÄ¿×Ö·û(°üÀ¨Áã¸ö×Ö·û)¡£ÔÚ MySQLÖУ¬SQLµÄģʽȱʡÊǺöÂÔ´óСдµÄ¡£ÏÂÃæÏÔʾһЩÀý×Ó¡£×¢ÒâÔÚÄãÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ