这个查询语句怎么写(100分)

  • 主题发起人 主题发起人 neel
  • 开始时间 开始时间
N

neel

Unregistered / Unconfirmed
GUEST, unregistred user!
表1
NameID Name
1 aaaa
2 bbbb
表2
ID NameID
1 1
1 2
查询结果
ID ALLName
1 aaaa bbbb
 
首先我感觉你这个问题没有讲清楚,不过我还是根据我的理解帮你写一个SQL语句:
select 表2.ID,表1.Name from 表1,表2 into #temp
where 表2.ID = 1 and 表1.NameID = 表2.NameID
declare @ID int,@Name varchar(80),@AllName varchar(800)
declare test_cursor scroll cursor
from select ID,Name from #temp
open test_cursor
declare @I int
set @I = 0
while @i < @@RowsCount
begin
fetch next from test_cursot into @ID,,@Name
set @AllName = @AllName + @Name
set @I = @I + 1
end
close test_cursor
deallocate test_cursor
select @ID,@AllName
 
关注! 学习!
 
to 晓风月
好像不对啊。。。
 
adoquery.clear;
selct name from 表1;
adouqery.open;
while not adoquery.eof do
begin
strs:='''+str+'''+adoquery.fieldvalues['name'];
adoquery.next;
end;
然后将名字和序号加入,看能行吗?
 
select distinct 表2.ID as ID,表1.Name as ALLName from 表2 t2,表2 t3,表1 t1
where t2.ID=t3.ID and t1.NameID=t3.NameID

 
好像不用过程不能做啊!,关注
 
不用过程!难
 
接受答案了.
 
多谢了,我中间多写了一个逗号。
 
你的答案不对,只不过最接近罢了
 
后退
顶部