日期:2014-05-17 浏览次数:20600 次
表usermessage(id,username,password,touxiang)和表table20(id,username,title,time,content), 其中usermessage和table20中有一共同字段username, 现在我想得到这样的结果:显示 表A的username,touxiang,表B的title、time、content , where条件是根据table20的id来查询,传入的参数是string id4 大概代码如下: string SqlStr4="select username,touxiang,title,time,content from usermessage and table20 where table20.id='"+id4+"'";
select a.username,a.touxiang,b.title,b.time,b.content from usermessage a left join table20 b on a.username=b.username where b.id=
------解决方案--------------------
select a.username,a.touxiang,b.title,b.time,b.content from usermessage a left join table20 b on a.username=b.username where b.id=
------解决方案--------------------
string SqlStr4="select a.username,a.touxiang,b.title,b.time,b.content from usermessage a,table20 b where a.username=b.username and b.id='"+id4+"'";
------解决方案--------------------
SELECT a.username , a.touxiang , b.title , b.time , b.content FROM usermessage a INNER JOIN table20 b ON A.username = b.username WHERE b.id = @id
------解决方案--------------------
select username,touxiang,title,time,content from usermessage a left join table20 b on a.id=b.id and a.username=b.username where b.id='"+id4+"'"