有这样的表
Table "checklist"
idCardno
name
permAddress
datetime
Table "persons"
name
idcardno
photo
现在我想要我的sqlquery
idCardno | name | permAddress | photo
-----------------------------------------------
A123456 | John Doe | 302 xyz | 1.gif
照片应该是idcardno的相应照片。
我怎样才能达到这样的结果?我的SQL查询是什么? 感谢
答案 0 :(得分:2)
select checklist.idCardno as idCardno, checklist.name as name, permAddress, photo
from checklist, persons
where checklist.idCardno = persons.idCardno
答案 1 :(得分:1)
您可以使用JOIN
SELECT checklist.idCardno, checklist.name, permAddress, photo
FROM checklist JOIN persons
ON checklist.idCardno = persons.idcardno
答案 2 :(得分:1)
SELECT
C.IDCARDNo
, C.name
, C.permAddress
, P.Photo
FROM checklist C
INNER JOIN persons P ON C.Idcardno = P.idCardno
答案 3 :(得分:1)
您需要使用JOIN
select C.idCardno,
C.name,
C.permAddress,
P.photo
from checklist C
join persons P
on C.idCardno=P.idCardno
答案 4 :(得分:1)
如果idCardno <-> idcardno
是两个表之间的共享键,并且输出中的名称是来自人的名称,只需使用JOIN:
SELECT c.idCardno, p.name, permAddress, photo FROM checklist c JOIN persons p ON c.idCardno = p.idcardno
答案 5 :(得分:0)
使用加入:
select
C.idCardno,C.name,C.permAddress,P.photo
from checklist C
join persons P
on C.idCardno=P.idCardno
参考链接以供参考:Join
答案 6 :(得分:0)
从核对清单中选择c.idCardno,c.name,c.permAddress,p.photo作为c左侧加入人员为c.idCardno = p.idCardno