我该怎么办,我需要从mysql的3个表中获取数据,这是我当前的查询。所有表均包含IDNO,其IDN为03A45。但是此查询不会返回任何结果:

SELECT *
  FROM father, mother, parents
 WHERE father.IDNO=mother.IDNO=parents.IDNO
   AND mother.IDNO='03A45'
   AND father.IDNO='03A45'
   AND parents.IDNO='03A45'


什么是正确的查询呢?
所有表都将IDNO作为主键。

最佳答案

这样的事情应该起作用:

select *
from
father
inner join mother on father.IDNO = mother.IDNO
inner join parents on mother.IDNO = parents.IDNO
where
father.IDNO = '03a45'

关于sql - 从mysql中的3个表读取问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2467460/

10-12 03:56