高手解决SQL语句中动态给WHERE条件
select distinct UserInfoID from HB_UserInfo order by UserInfoID
select Sum(ReadCount) as readcount,HB_UserInfo.UserName from HB_Post, HB_UserInfo where HB_Post.UserInfoID='12'
select UserName from HB_UserInfo where UserInfoID='12'
我要三句变一句 下面两句中的UserInfoID要改成遍历第一句中的结果集 动态给 比如:第一句结果集{1,2,3},那下面2句中的UserInfoID为1,2,3;结果是3条记录
有高手帮忙吗
------解决方案-------------------- select Sum(ReadCount) as readcount,HB_UserInfo.UserName from HB_Post, HB_UserInfo where HB_Post.UserInfoID in(select distinct UserInfoID from HB_UserInfo order by UserInfoID)
select UserName from HB_UserInfo where UserInfoID in(select distinct UserInfoID from HB_UserInfo order by UserInfoID)
------解决方案--------------------select Sum(ReadCount) as readcount,HB_UserInfo.UserName from HB_Post, HB_UserInfo where HB_Post.UserInfoID
in(select distinct UserInfoID from HB_UserInfo)
------解决方案--------------------select Sum(ReadCount) as readcount,HB_UserInfo.UserName from HB_Post, HB_UserInfo where HB_Post.UserInfoID
in(select distinct UserInfoID from HB_UserInfo)