热心网友
回答时间:2024-04-06 14:07
declare @result varchar(2500);
set @result = '' ;
select @result = @result + cast(value as varchar(50))+','
from 子表 where MainID='a'
select ID ,value,@result as ChindValue from 主表 where id='a'
可以把上面的语句看成一条来执行
收起
热心网友
回答时间:2024-04-06 14:07
select ID,value,m.ChildValue from 主表,(select value as ChildValue from 主表,子表 where 子表.MainID=主表.ID) m
where ID=a and value=b
收起
热心网友
回答时间:2024-04-06 14:08
select a,b,x,y,z
from 主表 a,(select x,a from 子表 where mainid=a and id =1)b,,(select x,a from 子表 where mainid=a and id =2)c,,(select x,a from 子表 where mainid=a and id =3)d
where a。id=a
收起
热心网友
回答时间:2024-04-06 14:09
Mysql中用GROUP_CONCAT()函数即可。
本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。
收起