"select (select LogisticsCompanyName from tb_LogisticsCompany where LogisticsCompanyID=a.LogisticsCompanyID) as 'LogisticsCompanyName',a.LogisticsCompanyOrderfrom,a.OrderfromID,b.MemberName,case a.OrderfromState when 0 then '等待发货' when 1 then '已发货' end as OrderfromState,a.AppendTime from tb_Orderfrom a inner join DeliverGoods_Address b on a.DeliverGoods_AddressID=b.ID where b.MemberID=(select MemberID from tb_Member where MemberName='{0}')"
dddddddddd
ddddddd
select *
(select LogisticsCompanyName from tb_LogisticsCompany where LogisticsCompanyID=a.LogisticsCompanyID)
as 'LogisticsCompanyName',
a.LogisticsCompanyOrderfrom,
a.OrderfromID,b.MemberName,
case a.OrderfromState
when 0 then '等待发货'
when 1 then '已发货' end
as OrderfromState,a.AppendTime
from tb_Orderfrom a
inner join DeliverGoods_Address b
on a.DeliverGoods_AddressID=b.ID
where b.MemberID=(select distinct MemberID from tb_Member where MemberName='{0}'
)
什么问题?
要保证select distinct MemberID from tb_Member where MemberName='{0}'
这句查出来的结果唯一才行
,否则就这样
select *
(select LogisticsCompanyName from tb_LogisticsCompany where LogisticsCompanyID=a.LogisticsCompanyID)
as 'LogisticsCompanyName',
a.LogisticsCompanyOrderfrom,
a.OrderfromID,b.MemberName,
可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......