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

SQL Server ÖйØÓÚEXCEPTºÍINTERSECTµÄÓ÷¨

ÊìÁ·Ê¹ÓÃSQL ServerÖеĸ÷ÖÖÓ÷¨»á¸ø²éѯ´øÀ´ºÜ¶à·½±ã¡£½ñÌì¾Í½éÉÜÒ»ÏÂEXCEPTºÍINTERSECT¡£×¢Òâ´ËÓï·¨½öÔÚSQL Server 2005¼°ÒÔÉÏ°æ±¾Ö§³Ö¡£
EXCEPTÊÇÖ¸ÔÚµÚÒ»¸ö¼¯ºÏÖдæÔÚ£¬µ«ÊDz»´æÔÚÓÚµÚ¶þ¸ö¼¯ºÏÖеÄÊý¾Ý¡£
INTERSECTÊÇÖ¸ÔÚÁ½¸ö¼¯ºÏÖж¼´æÔÚµÄÊý¾Ý¡£
²âÊÔÈçÏ£º
create table t1(id int,mark char(2))
go
create table t2(id int,mark char(2))
go
insert into t1
select 1,'t1' union all
select 2,'t2' union all
select 3,'t3' union all
select 4,'t4'
go
insert into t2
select 2,'t2' union all
select 3,'m3' union all
select 5,'m5' union all
select 6,'t6'
go
select * from t1
EXCEPT
select * from t2
go
select * from t1
INTERSECT
select * from t2
go
--EXCEPT½á¹û¼¯Îª
--1 t1
--3 t3
--4 t4
--INTERSECT½á¹û¼¯Îª
--2 t2
EXCEPTºÍINTERSECTµÄÓÅÏȼ¶£º
ΪÁ˲âÊÔËüÃÇÖ®¼äµÄÓÅÏȼ¶£¬ÔËÐÐÏÂÃæµÄ²âÊÔ´úÂë:
create table t3(int id,mark char(2))
go
insert into t3
select 3,'t3' union all
select 3,'r3' union all
select 5,'m5' union all
select 5,'r5' union all
select 7,'b7' union all
select 8,'b8'
go
select * from t1
EXCEPT
select * from t2
INTERSECT
select * from t3
--ÔËÐнá¹û
--1 t1
--2 t2
--3 t3
--4 t4

Ϊʲô»á³öÏÖÈçÉϽá¹ûÄØ£¬Çë¿´ÏÂÃæµÄÖ´Ðмƻ®£º
Ô­À´t2ºÍt3ÏȽøÐеÄINTERSECTÔËË㣬µÃ³ö5 m5½á¹û¼¯£¬ÔÙºÍt1½øÐÐEXCEPTÔËËã¡£
ÈçÐèתÔØ£¬Çë×¢Ã÷±¾ÎÄÔ­´´×ÔCSDN TJVictorרÀ¸£ºhttp://blog.csdn.net/tjvictor


Ïà¹ØÎĵµ£º

sql²éѯѡÔñ±íÖдÓ10µ½15µÄ¼Ç¼

      ORDER BY ×Ӿ䰴һÁлò¶àÁУ¨×î¶à 8,060 ¸ö×Ö½Ú£©¶Ô²éѯ½á¹û½øÐÐÅÅÐò¡£ÓÐ¹Ø ORDER BY ×Ó¾ä×î´ó´óСµÄÏêϸÐÅÏ¢£¬Çë²ÎÔÄ ORDER BY ×Ó¾ä (Transact-SQL)¡£
      Microsoft SQL Server 2005 ÔÊÐíÔÚ from ×Ó¾äÖÐÖ¸¶¨¶Ô SELECT ÁбíÖÐδָ¶¨µÄ±íÖеÄÁнøÐÐÅÅÐò¡£ORDE ......

hibernateÖ´ÐÐÔ­ÉúSqlÓï¾äµÄ·½·¨£¨×ª£©

http://www.thecloud.cn/study/program/java/597.html
hibernate3µÄHQL ÊÇÃæÏò¶ÔÏóµÄÓï·¨,ÒѾ­Ö§³Ö update ,delete fromÓï¾ä,µ«
Ä¿Ç°»¹²»Ö§³Öinsert intoÓï¾ä.
×öÏîÄ¿ÓÐʱºòµÄÈ·ÐèҪдԭÉúµÄsqlÀ´·½±ãweb¿ª·¢.
ÏÂÃæÊÇÎÒ×Ô¼º¹Äµ·³öÀ´µÄ·½·¨,Ï£Íû¶ÔÎÒºÍÅóÓÑÓÐËù°ïÖú.
ÔÚDaoÀïдһ¸ö·½·¨,ÈÃÎÒÃÇÔÚactionÀïµ÷ÓÃËü...
&nbs ......

SQL Server ÓÅ»¯´æ´¢¹ý³ÌµÄÆßÖÖ·½·¨

ÓÅ»¯´æ´¢¹ý³ÌÓкܶàÖÖ·½·¨£¬ÏÂÃæ½éÉÜ×î³£ÓõÄ7ÖÖ¡£
1.ʹÓÃSET NOCOUNT ONÑ¡Ïî
ÎÒÃÇʹÓÃSELECTÓï¾äʱ£¬³ýÁË·µ»Ø¶ÔÓ¦µÄ½á¹û¼¯Í⣬»¹»á·µ»ØÏàÓ¦µÄÓ°ÏìÐÐÊý¡£Ê¹ÓÃSET NOCOUNT ONºó£¬³ýÁËÊý¾Ý¼¯¾Í²»»á·µ»Ø¶îÍâµÄÐÅÏ¢ÁË£¬¼õСÍøÂçÁ÷Á¿¡£
2.ʹÓÃÈ·¶¨µÄSchema
ÔÚʹÓÃ±í£¬´æ´¢¹ý³Ì£¬º¯ÊýµÈµÈʱ£¬×îºÃ¼ÓÉÏÈ·¶¨µÄSchema¡£ÕâÑù¿ÉÒÔÊ ......

SQL Server ÈçºÎÔÚÔËÐÐʱÖرàÒë´æ´¢¹ý³Ì

ÓÐÁ½ÖÖ·½·¨¶¯Ì¬ÖرàÒë´æ´¢¹ý³Ì£º 1.ÔÚCreateʱ¼ÓÉÏRECOMPILEÑ¡Ïî CREATE PROCEDURE dbo.PersonAge (@MinAge INT, @MaxAge INT)
WITH RECOMPILE
AS
SELECT *
from dbo.tblTable 2.ÔÚÖ´ÐÐʱ¼ÓÉÏRECOMPILEÑ¡Ïî EXEC dbo.PersonAge 65,70 WITH RECOMPILE ²»ÍƼöʹÓõڶþÖÖ·½·¨£¬ÓÈÆäÔÚÉú²ú»·¾³ ......

sql serverÊý¾Ý¿â¶¨Ê±×Ô¶¯±¸·Ý

     1¡¢½øÈëÆóÒµ¹ÜÀíÆ÷ÖÐ->¹ÜÀí->sql server´úÀí->×÷Òµ£»
¡¡¡¡2¡¢Ð½¨×÷Òµ£¬×÷ÒµÃû³ÆËæ±ãÈ¡£¬ÀýÈ磺data±¸·Ý£¬ËùÓÐÕßÑ¡Ôñsa£¬µ±È»ÄãÒ²¿ÉÒÔÑ¡ÔñÆäËûÓû§£¬Ç°ÌáÊǸÃÓû§ÓÐÖ´ÐÐ×÷ÒµµÄȨÏÞ£»
¡¡¡¡3¡¢µã»÷²½Öè±êÇ©£¬½øÈë²½ÖèÃæ°å¡£Ð½¨²½Ö裬²½ÖèÃû¿ÉÒÔËæ±ãÌîд£¬Èç²½Öè1£¬ÀàÐͺÍÊý¾Ý¿âĬÈÏ£¬²» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ