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

sqlÓï¾ä²éѯ½á¹ûºÏ²¢union ºÍunion allÓ÷¨

sqlÓï¾ä²éѯ½á¹ûºÏ²¢union ºÍunion allÓ÷¨
 
--ºÏ²¢Öظ´ÐÐ
select * from A
union
select * from B
--²»ºÏ²¢Öظ´ÐÐ
select * from A
union all
select * from B
°´Ä³¸ö×Ö¶ÎÅÅÐò
--ºÏ²¢Öظ´ÐÐ
select *
from (
select * from A
union
select * from B) AS T
order by ×Ö¶ÎÃû
--²»ºÏ²¢Öظ´ÐÐ
select *
from (
select * from A
union all
select * from B) AS T
order by ×Ö¶ÎÃû
//sql server°æ
Select * from (
select top 2 id,adddate,title,url from bArticle where ClassId='1' order by adddate desc) A
Union All
Select * from (
select top 2 id,adddate,title,url from bArticle where ClassId='2' order by adddate desc) B
Union All
Select * from (
select top 2 id,adddate,title,url from bArticle where ClassId='3' order by adddate desc) C
Union All
Select * from (
select top 2 id,adddate,title,url from bArticle where ClassId='4' order by adddate desc) D
//mysql°æ
Select * from (
select id,adddate,title,url from bArticle where ClassId='1' order by adddate desc limit 0,2) A
Union All
Select * from (
select id,adddate,title,url from bArticle where ClassId='2' order by adddate desc limit 0,2) B
Union All
Select * from (
select id,adddate,title,url from bArticle where ClassId='3' order by adddate desc limit 0,2) C
Union All
Select * from (
select id,adddate,title,url from bArticle where ClassId='4' order by adddate desc limit 0,2) D
ÔÚDB2ÀïʹÓÃunionʱһ¶¨Òª×¢ÒâÏà¶ÔÓ¦µÄ×Ö¶ÎÒ»¶¨ÊÇÊý¾ÝÀàÐÍÒ»Ñù£¬Êä³öʱ¿ÉÒÔÈÎÒâÏÔʾµÄÁУ¬µ«²»ÄÜÊä³ö²»Í¬ÀàÐÍ»ò²»Í¬±í½á¹¹¡£ÒòΪÕâÑù»á³ö´í¡£


Ïà¹ØÎĵµ£º

¸öÈË×ܽáµÄ¼¸Ìõ±È½ÏÓÐÒâ˼µÄsqlÓï¾ä


 
--------------------------------------------------------------------
-- ×÷ÕߣºÕÅ°®¹ú
-- ÈÕÆÚ£º2010-01-23 15:00:17
-- ÃèÊö: һЩ±È½ÏÓÐÒâ˼µÄSQLÓï¾ä
-- Version:
--    Microsoft SQL Server 2005 - 9.00.3042.00 (Intel X86)
--    Feb  9 2007 22:47:0 ......

´«ÖDz¥¿Íjavaѧϰ sql¼òµ¥²éѯÓï¾ä

½ñÌìÎÒѧϰÁËsqlµÄ¼òµ¥²éѯÓï¾ä£¬
 
һЩ»ù±¾µÄ¸ÅÄ
1                  ϵͳȨÏÞ£ºÊý¾Ý¿âÖеĶÔÏó£¬ ±í£¬´´½¨±í£¬É¾³ý±í
2           ¶ÔÏóȨÏÞ£º¶ÔÊý¾ÝµÄÔö¡¢É¾¡¢¸Ä¡¢²é¡ ......

Sql Server ×Ö·û´®¾ÛºÏº¯Êý

 Sql Server ÓÐÈçϼ¸Ö־ۺϺ¯ÊýSUM¡¢AVG¡¢COUNT¡¢COUNT(*)¡¢MAX ºÍ MIN£¬µ«ÊÇÕâЩº¯Êý¶¼Ö»ÄܾۺÏÊýÖµÀàÐÍ£¬ÎÞ·¨¾ÛºÏ×Ö·û´®¡£Èçϱí:AggregationTable
Id Name
1 ÕÔ
2 Ç®
1 Ëï
1 Àî
2 ÖÜ
Èç¹ûÏëµÃµ½ÏÂͼµÄ¾ÛºÏ½á¹û
Id Name
1 ÕÔËïÀî
2 Ç®ÖÜ
ÀûÓÃSUM¡¢AVG¡¢COUNT¡¢COUNT(*)¡¢MAX ºÍ MINÊÇÎÞ·¨×öµ½µ ......

д³ö¸ßÐÔÄÜSQLÓï¾äµÄ35Ìõ·½·¨

£¨1£©ÕûºÏ¼òµ¥,ÎÞ¹ØÁªµÄÊý¾Ý¿â·ÃÎÊ£º
¡¡¡¡Èç¹ûÄãÓм¸¸ö¼òµ¥µÄÊý¾Ý¿â²éѯÓï¾ä,Äã¿ÉÒÔ°ÑËüÃÇÕûºÏµ½Ò»¸ö²éѯÖÐ(¼´Ê¹ËüÃÇÖ®¼äûÓйØϵ)
£¨2£©É¾³ýÖظ´¼Ç¼£º
¡¡¡¡×î¸ßЧµÄɾ³ýÖظ´¼Ç¼·½·¨ ( ÒòΪʹÓÃÁËROWID)Àý×Ó£º
¡¡¡¡DELETE from EMP E WHERE E.ROWID > (SELECT MIN(X.ROWID)
¡¡¡¡from EMP X WHERE X.EMP_NO = E.EM ......

C#ÏîÄ¿´ò°üÒÔ¼°×Ô¶¯°²×°SQL SeverÊý¾Ý¿â


±¾ÎĽ«½éÉÜC#ÏîÄ¿´ò°üÒÔ¼°×Ô¶¯°²×°SQL SeverÊý¾Ý¿â£¬°üÀ¨´´½¨²¿ÊðÏîÄ¿¡¢½«Ö÷³ÌÐòÏîÄ¿µÄÊä³öÌí¼Óµ½²¿ÊðÏîÄ¿ÖС¢´´½¨°²×°³ÌÐòÀà¡¢´´½¨×Ô¶¨Òå°²×°¶Ô»°¿òµÈµÈ¡£
 
’power by: landlordh   
’for 2000,xp,2003   
Module uninstall   
Sub Main ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ