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

²ËÄñѧSQLÓï¾ä

ΪÁË´ó¼Ò¸üÈÝÒ×Àí½âÎÒ¾Ù³öµÄSQLÓï¾ä£¬±¾Îļٶ¨ÒѾ­½¨Á¢ÁËÒ»¸öѧÉú³É¼¨¹ÜÀíÊý¾Ý¿â£¬È«ÎľùÒÔѧÉú³É¼¨µÄ¹ÜÀíΪÀýÀ´ÃèÊö¡£
¡¡¡¡1.ÔÚ²éѯ½á¹ûÖÐÏÔʾÁÐÃû£º
¡¡¡¡a.ÓÃas¹Ø¼ü×Ö£ºselect name as 'ÐÕÃû' from students order by age
¡¡¡¡b.Ö±½Ó±íʾ£ºselect name 'ÐÕÃû' from students order by age
¡¡¡¡2.¾«È·²éÕÒ:
¡¡¡¡a.ÓÃinÏÞ¶¨·¶Î§£ºselect * from students where native in ('ºþÄÏ', 'ËÄ´¨')
¡¡¡¡b.between...and£ºselect * from students where age between 20 and 30
¡¡¡¡c.“=”£ºselect * from students where name = 'Àîɽ'
¡¡¡¡d.like:select * from students where name like 'Àî%' (×¢Òâ²éѯÌõ¼þÖÐÓГ%”£¬Ôò˵Ã÷ÊDz¿·ÖÆ¥Å䣬¶øÇÒ»¹ÓÐÏȺóÐÅÏ¢ÔÚÀïÃ棬¼´²éÕÒÒÔ“ÀªÍ·µÄÆ¥ÅäÏî¡£ËùÒÔÈô²éѯÓГÀÄËùÓжÔÏó£¬Ó¦¸ÃÃüÁ'%Àî%';ÈôÊǵڶþ¸ö×ÖΪÀÔòӦΪ'_Àî%'»ò'_Àî'»ò'_Àî_'¡£)
¡¡¡¡e.[]Æ¥Åä¼ì²é·û£ºselect * from courses where cno like '[AC]%' (±íʾ»òµÄ¹Øϵ£¬Óë"in(...)"ÀàËÆ£¬¶øÇÒ"[]"¿ÉÒÔ±íʾ·¶Î§£¬È磺select * from courses where cno like '[A-C]%')
¡¡¡¡3.¶ÔÓÚʱ¼äÀàÐͱäÁ¿µÄ´¦Àí
¡¡¡¡a.smalldatetime£ºÖ±½Ó°´ÕÕ×Ö·û´®´¦ÀíµÄ·½Ê½½øÐд¦Àí£¬ÀýÈ磺
select * from students where birth > = '1980-1-1' and birth <= '1980-12-31'
¡¡¡¡4.¼¯º¯Êý
¡¡¡¡a.count()ÇóºÍ£¬È磺select count(*) from students (ÇóѧÉú×ÜÈËÊý)
¡¡¡¡b.avg(ÁÐ)Çóƽ¾ù£¬È磺select avg(mark) from grades where cno=’B2’
¡¡¡¡c.max(ÁÐ)ºÍmin(ÁÐ)£¬Çó×î´óÓë×îС
¡¡¡¡5.·Ö×égroup
¡¡¡¡³£ÓÃÓÚͳ¼Æʱ£¬Èç·Ö×é²é×ÜÊý£º
select gender,count(sno)
from students
group by gender
(²é¿´ÄÐŮѧÉú¸÷ÓжàÉÙ)
¡¡¡¡×¢Ò⣺´ÓÄÄÖֽǶȷÖ×é¾Í´ÓÄÄÁÐ"group by"
¡¡¡¡¶ÔÓÚ¶àÖØ·Ö×飬ֻÐ轫·Ö×é¹æÔòÂÞÁС£±ÈÈç²éѯ¸÷½ì¸÷רҵµÄÄÐŮͬѧÈËÊý £¬ÄÇô·Ö×é¹æÔòÓУº½ì±ð(grade)¡¢×¨Òµ(mno)ºÍÐÔ±ð(gender)£¬ËùÒÔÓÐ"group by grade, mno, gender"
select grade, mno, gender, count(*)
from students
group by grade, mno, gender
¡¡¡¡Í¨³£group»¹ºÍhavingÁªÓ㬱ÈÈç²éѯ1ÃÅ¿ÎÒÔÉϲ»¼°¸ñµÄѧÉú£¬Ôò°´Ñ§ºÅ(sno)·ÖÀàÓУº
select sno,count(*) from grades
where mark<60
group by sno
having count(*)>1
¡¡¡¡6.UNIONÁªºÏ
¡¡¡¡ºÏ²¢²éѯ½á¹û£¬È磺
SELECT * from students
W


Ïà¹ØÎĵµ£º

Ò»¸ö¶à±íǶÌײéѯµÄsqlÓï¾ä

select batch_no "Åú´ÎºÅ",get_id "·ÖÀà" from (
select(
select plan1.batch_no from product_plan plan1 where plan1.item_no=(select head1.product_code from wo_head head1 where head1.order_no =bbb)) batch_no, 
(select decode(get_id,'BUY','Í⹺¼þ','MAK','×ÔÖƼþ','MB','䶨') from item where item_ ......

SQL SERVER convertº¯ÊýÈÕÆÚ¸ñʽ»¯Ó¦ÓÃ

Sql Server ÖÐÒ»¸ö·Ç³£Ç¿´óµÄÈÕÆÚ¸ñʽ»¯º¯Êý
¡¡¡¡Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
¡¡¡¡Select CONVERT(varchar(100), GETDATE(), 1): 05/16/06
¡¡¡¡Select CONVERT(varchar(100), GETDATE(), 2): 06.05.16
¡¡¡¡Select CONVERT(varchar(100), GETDATE(), 3): 16/05/06
¡¡¡¡Select ......

Çå³ýSQLÊý¾Ý¿âÈÕÖ¾Îļþ


Çå³ýSQLÊý¾Ý¿âÈÕÖ¾Îļþ
/*--ѹËõÊý¾Ý¿âµÄͨÓô洢¹ý³Ì
ÓÐÁ½ÖÖ·½·¨ Ò»ÊÇѹËõÈÕÖ¾£¬¶þÊÇɾ³ýÈÕÖ¾¡£
Ò»¡¢Ñ¹ËõÈÕÖ¾¼°Êý¾Ý¿âÎļþ´óС
ÒòΪҪ¶ÔÊý¾Ý¿â½øÐзÖÀë´¦Àí
ËùÒÔ´æ´¢¹ý³Ì²»ÄÜ´´½¨ÔÚ±»Ñ¹ËõµÄÊý¾Ý¿âÖÐ
/*--µ÷ÓÃʾÀý
exec p_compdb 'test'
--*/
use master   --×¢Òâ,´Ë´æ´¢¹ý³ÌÒª½¨ÔÚmasterÊý¾Ý¿âÖÐ
go ......

SQL´¥·¢Æ÷Óï·¨²Î¿¼

ת×Ôhttp://www.tzwhx.com/newOperate/Html/3/31/311/16609.html
Óï·¨
CREATE TRIGGER trigger_name
ON { table | view }
[ WITH ENCRYPTION ]
{
    { { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] }
        [ WITH APPEND ]
   ......

SQL Server 2005 Express Edition Óû§ÊµÀý

Roger Wolter
ÊÊÓÃÓÚ£º
SQL Server 2005 Express Edition
ÕªÒª£º±¾ÎĽéÉÜ SQL Server 2005 Express Edition ÖеÄÓû§ÊµÀý£¬ÒÔ¼°ÈçºÎʹÓÃËüÃÇÀ´¼ò»¯Ïò Visual Studio ÏîÄ¿Ìí¼ÓÊý¾Ý¿â¹¦ÄܵIJÙ×÷¡£
Äú¿ÉÒÔÏÂÔر¾ÎÄʹÓÃµÄ Microsoft Word °æ±¾¡£
±¾Ò³ÄÚÈÝ
¼ò½é
¸½¼ÓÊý¾Ý¿âÎļþ
AttachDBFilename
Óû§ÊµÀý
´ò¿ªÓ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ