select a.*,b.* from 表1 a,表2 b where a.ID IN(条件) and b.ID in(条件2) 上面返回的是: select * from 表1 where ID IN(条件) 和 select * from 表2 where ID in(条件2) 的笛卡尔积,即两个查询结果的条数相乘,当然是N多个,你如果可以加上: select a.*,b.* from 表1 a,表2 b where a.ID IN(条件) and b.ID in(条件2) and a.id=b.id就少了
try this would help:select * from(select a.*,b.* from 表1 a,表2 b where a.ID IN(条件) and b.ID in(条件2) and a.id=b.id) as tb1
上面返回的是:
select * from 表1 where ID IN(条件)
和
select * from 表2 where ID in(条件2)
的笛卡尔积,即两个查询结果的条数相乘,当然是N多个,你如果可以加上:
select a.*,b.* from 表1 a,表2 b where a.ID IN(条件) and b.ID in(条件2) and a.id=b.id就少了