关于多表联合查询的SQL语句。。。求解释下。。。。
Stringsql="selectdistinctf.*fromqx_grouppermita,qx_usergroupb,xt_user"+"c,qx_modeld,q...
String sql = "select distinct f.* from qx_grouppermit a,qx_usergroup b,xt_user" +
" c,qx_model d,qx_model e,qx_model f where a.groupcode=b.groupcode " +
" and b.userid=c.userid and c.UserName='"+ UserName +"' and a.modelcode=d.modelcode " +" and d.parentmodel=e.modelcode and e.parentmodel=f.modelcode order by f.showorder"; 展开
" c,qx_model d,qx_model e,qx_model f where a.groupcode=b.groupcode " +
" and b.userid=c.userid and c.UserName='"+ UserName +"' and a.modelcode=d.modelcode " +" and d.parentmodel=e.modelcode and e.parentmodel=f.modelcode order by f.showorder"; 展开
2个回答
展开全部
--T-SQL语句表示如下,没什么可说的 就是多表条件联接而已,取F表不重复的条件联接下的所有记录
--输入参数为UserName,最后再以f.showorder排序
select distinct f.*
from qx_grouppermit a,qx_usergroup b,xt_user c,qx_model d,qx_model e,qx_model f
where a.groupcode=b.groupcode
and b.userid=c.userid
and c.UserName=@UserName--输入参数@UserName
and a.modelcode=d.modelcode
and d.parentmodel=e.modelcode
and e.parentmodel=f.modelcode
order by f.showorder
--输入参数为UserName,最后再以f.showorder排序
select distinct f.*
from qx_grouppermit a,qx_usergroup b,xt_user c,qx_model d,qx_model e,qx_model f
where a.groupcode=b.groupcode
and b.userid=c.userid
and c.UserName=@UserName--输入参数@UserName
and a.modelcode=d.modelcode
and d.parentmodel=e.modelcode
and e.parentmodel=f.modelcode
order by f.showorder
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询