mssql 语句 优化
rs.open"select*,(selectshfrom[gy_list]wheredd_id=[dd_list].id)assh,(selectsh_timefrom...
rs.open "select *,(select sh from [gy_list] where dd_id=[dd_list].id) as sh,(select sh_time from [gy_list] where dd_id=[dd_list].id) as sh_time,(select sh_name from [gy_list] where dd_id=[dd_list].id) as sh_name from [dd_list] "&ss&" order by id desc",conn,1,1
rs1.open "select scdw from [scjh] where dd_id="&rs("id")&"",conn,1,1
do while not rs1.eof
scdw=scdw&" "&rs1("scdw")&""
rs1.movenext
loop
rs1.close
rs.close 展开
rs1.open "select scdw from [scjh] where dd_id="&rs("id")&"",conn,1,1
do while not rs1.eof
scdw=scdw&" "&rs1("scdw")&""
rs1.movenext
loop
rs1.close
rs.close 展开
3个回答
展开全部
select *,(select sh from [gy_list] where dd_id=[dd_list].id) as sh,
(select sh_time from [gy_list] where dd_id=[dd_list].id) as sh_time,
(select sh_name from [gy_list] where dd_id=[dd_list].id) as sh_name
from [dd_list]
order by id desc
--等价于下面,把A.*换成你具体需要的列字段,SELECT * ..要尽量不用
SELECT A.*,B.sh,B.sh_time,B.sh_name
FROM [dd_list] A,[gy_list] B
WHERE A.ID=B.dd_id
(select sh_time from [gy_list] where dd_id=[dd_list].id) as sh_time,
(select sh_name from [gy_list] where dd_id=[dd_list].id) as sh_name
from [dd_list]
order by id desc
--等价于下面,把A.*换成你具体需要的列字段,SELECT * ..要尽量不用
SELECT A.*,B.sh,B.sh_time,B.sh_name
FROM [dd_list] A,[gy_list] B
WHERE A.ID=B.dd_id
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询