ÇóÒ»ÌõSQLÓï¾ä¡£ÈçÏ - .NET¼¼Êõ / C#
ÇóÒ»ÌõSQLÓï¾ä¡£ÈçÏÂ
±í a
id Ö÷¼ü
²¿ÃÅ id
Ô±¹¤ÐÕÃû
ѧÀú
±í b
id Ö÷¼ü
²¿ÃÅÃû
±í c
ѧÀú id
ѧÀúÃû
Çó±í
²¿ÃÅa ²¿ÃÅb ²¿ÃÅc ²¿ÃÅd
³õÖÐ x x x x
¸ßÖÐ x x x x
´óר x x x x
´óѧ x x x x
ͳ¼Æ ÈËÊý
°ï¶¥~~
x x x x
ÊÇ´ú±íÈËÊý°É¡£
x´ú±íÈËÊý
select b.*,c.*,(select count(0) from a where ²¿ÃÅId=b.id and ѧÀúid=c.id) as count from b,c
ÏÈÖ´Ðп´¿´°É
²»Ðа¡¡£ÐÖµÜ
ʲôÊý¾Ý¿â£¿Õâ²»ÊǵäÐ͵Ä͸ÊÓ±íÎÊÌâÂð£¿Ò»°ã³£¹æ·½·¨Ê¹ÓÃcase whenÓï¾äÀ´²úÉú¼ÆËãÁС£
SQL code:
--create table
create table #a
(
aid int identity(1,1) primary key,
bid int,
uname varchar(50),
cid int
)
create table #b
(
bid int identity(1,1) primary key,
bname varchar(50)
)
create table #c
(
cid int identity(1,1) primary key,
cname varchar(50)
)
--insert into
insert into #b(bname) values('b1')
insert into #b(bname) values('b2')
insert into #b(bname) values('b3')
insert into #b(bname) values('b4')
insert into #c(cname) values('²¿ÃÅa')
insert into #c(cname) values('²¿ÃÅb')
insert into #c(cname) values('²¿ÃÅc')
insert into #c(cname) values('²¿ÃÅd')
insert into #a(bid,uname,cid) values(1,'³õÖÐ',1
Ïà¹ØÎÊ´ð£º
DataSetµ¼³öxml Åú´¦Àí(Ñ»·)µÃÔõô´¦Àí
XMLÎļþ
<A>
<B>
<C>
</C>
&nb ......
sqlµÄÈí¼þÔÚÄÄÀï¿ÉÒÔÏ°¡£¡ÔÚÍøÉÏÕÒÁËÂù¶à¶¼Óò»ÁË°¡
Ëæ±ã¸ãÒ»D°æ°É£¬
ѸÀ×µÚÒ»¸ö¾Í¿ÉÒÔÓÃ
2000,2005¶¼ÕâÑù
http://119.147.41.16/down?cid=0698C2D64D7D637D90A6D2482298E6717D4F15CD&t=2&fmt=-1 ......
×Ö¶Î1,×Ö¶Î2.....×Ö¶ÎN,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
ÏëÒªµÄ½á¹ûÊÇ:
1,Na ......
ÐèÇóÈçÏ£º
ѧԺ academy£¨aid,aname£©
°à¼¶ class£¨cid,cname,aid£©
ѧÉú stu(sid,sname,aid,cid)
סËÞÇø region(rid,rname)
ËÞÉáÂ¥ build(bid,rid,bnote) bnoteÊÇ¡®ÄС¯/¡®Å®¡¯
ËÞÉá dorm(did,rid,bid£¬bedn ......
¸÷λºÃ£¬ÎÒ¸Õ°ÑÒ»¸öASPÍøÕ¾ÉèÖúÃÁË£¬Ò²ÄÜÕý³£·ÃÎÊ¡£µ«ÊÇÔÚÎÒ±¾»úÉϲ»ÄÜ´ò¿ªadmin\login.asp,ËùÒÔÎÞ·¨ÊµÏÖºǫ́¹ÜÀí¡££¨´íÎóÌáʾÎÞ·¨ÕÒµ½ÍøÒ³£¬´úÂë404£¬ÎҵIJÙ×÷ϵͳÊÇwin2000 server)
µ«ÊÇÆæ¹ÖµÄÊÇÔÚ¾ÖÓòÍøµÄÆäËû» ......