select * from tb1,tb2 where tb1.id = tb2.tb1id and tb1.条件=?? and tb2.条件=??
select * from tb1 left join tb2 on tb1.XX=tb2.XX
select t1.* , t2.* from t1 , t2 where t1.关键字 = t2.关键字 and t1.条件 = ... and t2.条件 = ...
估计是and的条件导致你想要的数据跟实际的有差异呀!你可以把你的表结构,查询语句贴出来给大家看看呀
以上的查询方式我都试过了 select a.communiquecode,max(a.commname) as commname,max(a.spec) as spec,max(isnull(b.qua,0))as qua from v_bu_commcptype a left join bu_inventorycomm b on a.communiquecode=b.communiquecode where a.class in (1173,1174) and inventid=1199 group by a.communiquecode a 表里有394条数据 b表里有194条数据。我连b表的原因就是想把b表里的qua取出来。
select communiquecode,commname,spec,qua from bu_inventorycomm where inventid=1199里面有194条数据。select class,communiquecode,commname,spec from v_bu_commcptype where class in (1173,1174)里面有394条数据我想把这两个表连起来为的是把下面这个表里的数据都取出来。然后把上面那个表里对应的qua取出来。
select t1.* , t2.* from bu_inventorycomm t1 , v_bu_commcptype t2 where t1.communiquecode = t2.communiquecode and t1.inventid=1199 and t2.class in (1173,1174)
select a.communiquecode,max(a.commname) as commname,max(a.spec) as spec,max(isnull(b.qua,0))as qua
from v_bu_commcptype a left join bu_inventorycomm b
on a.communiquecode=b.communiquecode where a.class in (1173,1174) and inventid=1199 group by a.communiquecode a 表里有394条数据 b表里有194条数据。我连b表的原因就是想把b表里的qua取出来。
如果有多表,表之间如何关联?
发帖注意事项
http://topic.csdn.net/u/20091130/21/fb718680-98ff-4afb-98d8-cff2f8293ed5.html?24281
from bu_inventorycomm t1 , v_bu_commcptype t2
where t1.communiquecode = t2.communiquecode
and t1.inventid=1199 and t2.class in (1173,1174)