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

SQL server µÚÈýƪ ¶à±íÁª½Ó²éѯ

        ¶à±íÁª½Ó²éѯ
Ò»¡¢¶à±íÁª½Ó²éѯµÄ·ÖÀà
¶à±íÁª½Ó²éѯʵ¼ÊÉÏÊÇͨ¹ý¸÷¸ö±íÖ®¼ä¹²Í¬ÁеĹØÁªÐÔÀ´²éѯÊý¾ÝµÄ£¬ËüÊǹØϵÊý¾Ý¿â²éѯ×îÖ÷ÒªµÄÌØÕ÷¡£
Áª½Ó²éѯ¿É·ÖΪÈý´óÀ࣬·ÖÁíΪ£º
1£®  ÄÚÁª½Ó¡£
2£®  ÍâÁª½Ó¡£
3£®  ½»²æÁª½Ó¡£
ÄÇôÎÒÃÇÒ»ÆðÀ´¿´Ò»ÏÂÈçºÎʹÓöà±íÁª½Ó²éѯ¡£
A.       ÄÚÁª½Ó£ºÄÚÁª½ÓÊÇ×îµäÐÍ¡¢×î³£ÓõÄÁª½Ó²éѯ£¬Ëü¸ù¾Ý±íÖй²Í¬µÄÁÐÀ´½øÐÐÆ¥Å䣬ֻÓÐÂú×ãÆ¥ÅäµÄÌõ¼þµÄÊý¾Ý²ÅÄܱ»²éѯ³öÀ´¡£Í¨³££¬Á½¸ö±í´æÔÚÖ÷Íâ¼ü¹Øϵʱ»áʹÓõ½ÄÚÁª½Ó²éѯ¡£
ÄÚÁª½á³£Ê¹ÓÓ=”±È½ÏÔËËã·ûÀ´ÅжÏÁ½ÁÐÊý¾ÝÊÇ·ñÏàµÈ£¬ÔÚÕâÀïÎÒÃÇͨ¹ý¼¸¸öʵÀýÀ´Ñ§Ï°ÄÚÁª½Ó²éѯ¡£
a)        ÏÈÔÚSQL Server 2005ÖÐн¨Á½¸ö±íusersTableºÍusersNote,Á½±íµÄÄÚÈÝÈçÏÂÃæµÄͼÖÐËùʾ¡£
 
 
 
 
 
±íusersTable
 
±íusersNote
 
 
b)        ÔÚ½¨ºÃÏàÓ¦µÄ±íºó£¬ÎÒÃǾͿÉÒÔ½øÐжà±í²éѯÁË£¬Ê×ÏÈÄÚÁª½ÓÎÒÃÇÓÐÁ½ÖÖ·½Ê½À´²éѯ¡£
µÚÒ»ÖÖ£ºÖ±½ÓÔÚWhereÌõ¼þÀïͨ¹ý±í´ïʽÀ´½øÐбíÖ®¼äµÄ¹ØÁª¡£
 
select usersTable.myuser,usersTable.mypwd,
usersNote.useraddress,userphonenumber
--²éѯÏÔʾdbo.usersTableºÍdbo.usersNote±íÖеÄÖ¸¶¨µÄÄÚÈÝ
from dbo.usersTable,dbo.usersNote
--ÄÚÁª½ÓÁ½±í
where usersTable.myuser=usersNote.username
--Á½±íÆ¥ÅäµÄÌõ¼þ
 
ÔÚSQL 2005ÖеIJéѯ½á¹ûÈçÏ£º
 
 
µÚ¶þÖÖ£ºÍ¨¹ýʹÓÃInner Join¹Ø¼ü×Ö½øÐбíÖ®¼äµÄ¹ØÁª¡£
 
select usersTable.myuser,usersTable.mypwd,
usersNote.useraddress,userphonenumber
 
from dbo.usersTable inner join dbo.usersNote
on (usersTable.myuser=usersNote.username)
 
²éѯ½á¹ûÈçÏ£º
 
 
B.        ÍâÁª½Ó£ºÍâÁª½ÓÓÖ¿É·ÖΪ×óÍâÁª½Ó¡¢ÓÒÍâÁª½Ó¡¢ÍêÕûÁª½ÓÈýÖÖ¡£
ÍâÁª½ÓÓëÄÚÁª½ÓÇø±ðÔÚÓÚ£¬²»½öÏÔʾÁ½¸ö±í¹ØÁª×Ö¶ÎÆ¥ÅäµÄ¼Ç¼£¬Í¬Ê±²»Æ¥Åä¼Ç¼¸ù¾ÝÍâÁª½ÓÀàÐÍÒ²»áÏÔʾ¡£
a)        ×óÍâÁª½Ó£ºLeft Join   »ò  Left Outer Join¡£
×óÍâÁª½ÓµÄ½á¹û¼¯°üÀ¨Left Join×Ó¾äÖÐÖ¸¶¨µÄ×ó±íµÄËùÓÐÐУ¬¶ø²»½ö½öÊÇÁª½ÓÁÐËùÆ¥ÅäµÄÐС£Èç¹û


Ïà¹ØÎĵµ£º

SQL ServerÖеÄÐÐÁе¹Öü¼ÇÉ

ÐÐÁе¹ÖÃÔÚsql serverÖÐÊÇÒ»Öֺܳ£¼ûµÄ¼¼ÇÉ£¬ÔÚ×öÓ¦ÓÃϵͳµÄʱºò£¬¾­³£ÐèÒª×öһЩͳ¼Æ¹¦ÄܱÜÃâ²»ÁËʹÓÃÐÐÁе¹ÖÃÕâ¸ö¼¼ÇÉ£¬ÎÒССµÄ×öÁËÒ»ÏÂ×ܽ᣺
µÚÒ»ÖÖ£ºsql server 2000ÖÐʹÓÃcase½øÐÐÐÐÁе¹ÖÃ
create table RowCellConvertTest
(
 grade varchar(50),
 sex varchar(50),
 studentCount int
)
......

sqlÖÐand¼°or µÄÖ´ÐÐЧÂÊ

Ó¦ÓÃÖз¢ÏÖsqlÖеÄand¼°orµÄÖ´ÐÐЧÂÊÎÊÌâ
£ó£ñ£ìÓï¾ä£¬ÎªÊ²Ã´°Ñ×îºóµÄ£ï£ò»»³É£á£î£ä£¬²éѯµÄ¾ÍºÜ¿ì£¬Ê¹ÓõÄÊÇmssql·¶ÀýÖÐnorthwindÊý¾Ý¿âΪÀý£¬
select * from Orders a left join [Order Details] b on a.orderid = b.orderid
where a.customerid like '%ics%' or b.productid in (42,72)
×·×ÙÁËÓï¾äµÄÖ´Ðз½°¸,·¢ÏÖ ......

sql server³öÏÖÑ¡¶¨µÄÓû§ÓµÓжÔÏó¶øÎÞ·¨É¾³ýµÄ´¦Àí


sql server³öÏÖÑ¡¶¨µÄÓû§ÓµÓжÔÏó¶øÎÞ·¨É¾³ýµÄ´¦Àí
2006-4-5 19:50:00
·½·¨Ò»
Ê×ÏÈÄãÐèÒª×öµÄµÚÒ»¼þÊÂ
ÆóÒµ¹ÜÀíÆ÷-¡µÑ¡Ôñ·þÎñÆ÷-¡µÊô***-¡µ·þÎñÆ÷ÉèÖÃ-¡µÌôÉÏÔÊÐí¶ÔϵͳĿ¼¡£¡£¡£-¡µÈ·¶¨
µÚ¶þ²½
ÕÒµ½ÄãµÄÊý¾Ý¿âÕÒµ½sysusers±íÄÇÄãÒÔÇ°µÄÓû§É¾³ý
µÚÈý²½»ØÈ¥°ÉÊô***Öµ¸Ä»ØÀ´
µÚËIJ¿Öؽ¨Óû§¼´¿É
·½·¨¶þ
¶ ......

Ö´Ðлº´æÒÔÓÅ»¯SQL ServerµÄÄÚ´æÕ¼ÓÃ

×÷Õߣºsuperhasty
  2007-11-29
ÔÚÂÛ̳Éϳ£¼ûÓÐÅóÓѱ§Ô¹£¬ËµSQL ServerÌ«³ÔÄÚ´æÁË¡£ÕâÀï±ÊÕ߸ù¾Ý¾­Ñé¼òµ¥½éÉÜÒ»ÏÂÄÚ´æÏà¹ØµÄµ÷ÓÅ֪ʶ¡£Ê×ÏÈ˵Ã÷Ò»ÏÂSQL
ServerÄÚ´æÕ¼ÓÃÓÉÄļ¸²¿·Ö×é³É¡£SQL ServerÕ¼ÓõÄÄÚ´æÖ÷ÒªÓÉÈý²¿·Ö×é³É£ºÊý¾Ý»º´æ(Data
Buffer)¡¢Ö´Ðлº´æ(Procedure Cache)¡¢ÒÔ¼°SQL ServerÒýÇæ³ÌÐò¡£S ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ