表a为主表
id
xm
gh
表b为从表
id
xx
cc
select a.*,b.* from a,b where a.id=b.id and a.id=1
这样一来,上面那个记录几为多条记录,
我想的到
select * from a where a.id=1(一条记录)
再把
select xx from b where b.id=1中的结果和上面几录合在一起
如何写
select distinct a.*,b.* from a,b where a.id=b.id and a.id=1
这是因为你的b表中id=1的记录有很多条的原因,
select c.*,b.*
from (select 1,xm,sum(gh) as gh from a where a.id=1 group by xm ) c , b where
c.id=b.id
select a.*,b.xx from a,b where a.id=b.id and a.id=1
select a.id,a.xm,a.gh,b.xx from a,b where a.id=b.id and a.id=1