求一个简单的多表查询语句
表tzsb:字段:id,gxrq
表azsqd:字段:id,spdw
表azysd:字段:id,ysdw
现在我要查出三个表中指字的字段,并给三个表分别起别名a,b,c,条件是三个表中的id都等于2007
谁帮帮忙?
------解决方案--------------------select tzsb.gxrq as a,azsqd.spdw as b,azysd.ysdw as c from tzsb,azsqd,azysd where tzsb.id=azsqd.id and tzsb.id=azysd.id and tzsb.id=2007
------解决方案--------------------這個意思?
Select * From tzsb A
Where id = 2007
Union All
Select * From azsqd B
Where id = 2007
Union All
Select * From azysd C
Where id = 2007
------解决方案--------------------select * --- 把*换成你要指字的字段
from tzsb a , azsqd b , azysd c
where a.id=b.id and a.id=c.id and a.id = '2007 '
------解决方案--------------------還是這個意思?
Select
*
From
tzsb A
Inner Join
azsqd B
On A.id= B.id
Inner Join
azysd C
On A.id= C.id
Where A.id = 2007
------解决方案--------------------select a.id,a.gxrq,b.spdw,c.ysdw
from tzsb a , azsqd b , azysd c
where a.id = '2007 ' and b.id = '2007 ' and c.id = '2007 '