【发布时间】:2013-12-26 09:14:29
【问题描述】:
select
t.Sno, t.childid,
(select customername as n from customerprofile c where c.cusid = t.childid) as name,t.earnedmoney as commission,
(select p.bookingamt from propertyregistration p, customerprofile c where p.applicationno = c.applicationno and c.cusid = t.childid) as bookingamt,
(select p.totalarea from propertyregistration p, customerprofile c where p.applicationno = c.applicationno and c.cusid = t.childid) as totalarea ,
(select childid from tbl_level where parentid = t.childid) as child
from
tbl_level t
where
parentid = @id
这是过程
(select childid from tbl_level where parentid = t.childid) as child
如果只有一条记录,它很容易获取
在多条记录中,子查询返回多个值会报错
请帮助我如何检索多条记录
【问题讨论】:
-
当
parentid有 2 个或更多配置文件 (customerprofile) 或propertyregistration中有 2 个或更多行时,应该如何查询? -
Bad habits to kick : using old-style JOINs - 旧式 逗号分隔的表格列表 样式已随 ANSI-92 SQL 标准(超过 20 年前)
-
实际上我想显示特定记录的每个子项
标签: sql sql-server select left-join sql-server-group-concat