sqlµÝ¹é²éѯ
ÔÚ¹¤×÷ÖÐÓöµ½Ò»¸öÎÊÌâ,ÊÇÐèÒªsqlµÝ¹é²éѯµÄ.²»¶®,ÓÚÊǵ½csdnÉÏÈ¥ÎÊ,ÄÇÀïµÄЧÂÊÕæÊǷdz£¸ß,ÎÒÒÔǰҲûÔÚÉÏÃæÎʹýÎÊÌâ.
ÎÊÌâÃèÊö:
ÎÒÓÐÒ»¸ö±í½á¹¹ÈçÏÂ:
id upperid
1 2
3 2
4 1
5 3
¾ßÌå²ã´Î²»ÖªµÀ,ÎÒÏëÓõݹésqlÓï¾ä°ÑËùÓÐÊôÓÚij¸öupperidµÄÊý¾Ý,°üÀ¨ËüµÄ×ÓÊ÷,¶¼¶Á³öÈ¥£¬ÇëÎÊÓ¦¸Ã×ÓÔõôд?
±ÈÈç˵ upperid =2
ÄÇôÏÈÕÒµ½1,3,È»ºóÔÙÓÉ1,3ÕÒµ½4,5
ʹÓÃsqlÓï¾äʵÏÖ
ÓÐÁ½Î»ÅóÓѶ¼¸øÁ˻ظ´:
fa_ge(鶴嘯¾ÅÌì)
Create table t(id int,upperid int)
insert into t
select 1, 2
union all select 3, 2
union all select 4, 1
union all select 5, 3
select * from t
create function aa(@upperid int)
returns @t table (id int,upperid int,level int)
as
begin
declare @i int
set @i=1
insert into @t
select *,@i from t where upperid=@upperid
while @@rowcount>0
begin
set @i=@i+1
insert into @t
select a.*,@i from t a left join @t b on a.upperid=b.id
where b.level=@i-1
end
return
end
select * from dbo.aa(1)
id upperid level
----------- ----------- -----------
4 1 1
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
select * from dbo.aa(2)
id upperid level
----------- ----------- -----------
1 2 1
3 2 1
4 1 &nbs
Ïà¹ØÎĵµ£º
SQL Server 2008 R2µÄÊ®´ó±ä»¯£¨ÉÏ£©£¬SQL Server 2008 R2µÄÊ®´ó±ä»¯£¨Ï£© ÕâÊ®´óÌØÐÔÖÐÎұȽϸÐÐËȤµÄÊÇStreamInsight£ºÍ¨¹ýSQL Server 2008 R2еÄStreamInsight×é¼þ£¬Microsoft½øÈëÁ˸´ÔÓʼþ´¦Àí(Complex Event Processing£¬CEP)¾ºÕù£¬ÆäÖÐÏà¹ØµÄ¹©Ó¦ÉÌ»¹ÓÐOracle¡¢IBMºÍStreamBase¡£
SQL Server 2008 R2ÒýÈëStreamIn ......
SQL Server 2008 ¶¨Ê±×÷ÒµµÄÖƶ¨
--1.´ò¿ª¡¾SQL Server Management Studio¡¿£¬ÔÚ¡¾¶ÔÏó×ÊÔ´¹ÜÀíÆ÷¡¿ÁбíÖÐÑ¡Ôñ¡¾SQL Server ´úÀí¡¿£»
--2.Êó±êÓÒ»÷¡¾SQL Server ´úÀí¡¿£¬Ñ¡Ôñ¡¾Æô¶¯(S)¡¿£¬ÈçÒÑÆô¶¯£¬¿ÉÒÔÊ¡ÂԴ˲½Ö裻
--3.Õ¹¿ª¡¾SQL Server ´úÀí¡¿ÁÐ±í£¬ÓÒ»÷¡¾×÷Òµ¡¿-->¡¾Ð½¨×÷Òµ¡¿£»
--3.1 ÔÚ¡¾³£¹æ¡¿Ñ¡ÏÖУº
......
¡¡²Ù×÷·ûÓÅ»¯
¡¡¡¡IN ²Ù×÷·û
¡¡¡¡ÓÃINд³öÀ´µÄSQLµÄÓŵãÊDZȽÏÈÝÒ×д¼°ÇåÎúÒ׶®£¬Õâ±È½ÏÊʺÏÏÖ´úÈí¼þ¿ª·¢µÄ·ç¸ñ¡£
¡¡¡¡µ«ÊÇÓÃINµÄSQLÐÔÄÜ×ÜÊDZȽϵ͵ģ¬´ÓORACLEÖ´ÐеIJ½ÖèÀ´·ÖÎöÓÃINµÄSQLÓë²»ÓÃINµÄSQLÓÐÒÔÏÂÇø±ð£º
¡¡¡¡ORACLEÊÔͼ½«Æäת»»³É¶à¸ö±íµÄÁ¬½Ó£¬Èç¹ûת»»²»³É¹¦ÔòÏÈÖ´ÐÐINÀïÃæµÄ×Ó²éѯ£¬ÔÙ²éѯÍâ²ãµÄ±í¼Ç¼£ ......
ÔÚwindows XP SP3 ÖÐÊÇ¿ÉÒÔ°²×° SQL Server 2005 µÄ²»»áÓмæÈÝÎÊÌâ ÎÒÔÚ°²×°µÄʱºò¾ÍʲôÎÊÌⶼû¿´µ½ °²×°ºÃºó¸½¼ÓÒ»¸öÊý¾Ý¿â ÓÃBorland JBuilder 2006 Enterprise ºÍeclipse ҲûÎÊÌâ
SQL2005 ·ÖÎå¸ö°æ±¾£¬ÈçÏÂËùÁУ¬
¡¡¡¡1.Enterprise(ÆóÒµ°æ),
2.Development(¿ª·¢°æ),
¡¡¡¡3.Workgroup,(¹¤×÷Ⱥ°æ)
¡¡¡¡4.St ......
asp.net(C#)ʵÏÖSQL2000Êý¾Ý¿â±¸·ÝºÍ»¹Ô
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.Htm ......