这样的非关系型数据库怎么查询出值来?解决马上给分
http://www.njcpp.cn/download/1.jpg
数据库结构图在上面的地址里面,Ad1,Ad2,Ad3,Ad4对应的是Net_desklist表中的ID值(int),我是想select Net_netbar过后的ID值全部替换成AdAddress中的值该怎么写?谢谢了 ,csdn不能贴图就只好写图片地址了,麻烦了
图片地址
http://www.njcpp.cn/download/1.jpg
------解决方案--------------------select
a.ID,
a.NetBarID,
a.NetBarName,
Ad1=b.AdAddress,
Ad2=c.AdAddress,
Ad3=d.AdAddress,
Ad4=e.AdAddress,
a.Ad5,--还要不要替换,要再JOIN一个,下同。
a.AdFlash,
a.Http
from Net_netbar a
join Net_desklist b
on a.Ad1=b.ID
join Net_desklist c
on a.Ad2=c.ID
join Net_desklist d
on a.Ad3=d.ID
join Net_desklist e
on a.Ad4=e.ID
------解决方案----------------------为以防空的出现,使用左连接
select t.id , isnull(t1.addr1, ' ') addr1,isnull(t2.addr2, ' ') addr2,isnull(t3.addr3, ' ') addr3,isnull(t4.addr4, ' ') addr4
from net_netbar a
left join (select a.id , b.adaddress addr1 from net_netbar a ,net_desklist b where a.ad1 = b.id) t1 on t.id = t1.id
left join (select a.id , b.adaddress addr2 from net_netbar a ,net_desklist b where a.ad2 = b.id) t2 on t.id = t2.id
left join (select a.id , b.adaddress addr3 from net_netbar a ,net_desklist b where a.ad3 = b.id) t3 on t.id = t3.id
left join (select a.id , b.adaddress addr4 from net_netbar a ,net_desklist b where a.ad4 = b.id) t4 on t.id = t4.id