且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

简单但嵌套的SELECT查询

更新时间:2022-11-05 17:33:27

我认为您想使用LEFT JOIN:

SELECT c.value, d.value 
FROM a
LEFT JOIN b
    ON a.id = b.idy
LEFT JOIN c
    ON b.idx = c.id
LEFT JOIN d
    ON b.idx = d.id
WHERE a.name = "test" 

使用逗号联接语法是INNER JOIN,它要求所有表中的记录均可用.

Using the comma join syntax is an INNER JOIN which requires that the records be available in all tables.

如果您在查看JOIN语法时需要帮助,则有一个有用的指南:

If you need help in reviewing JOIN syntax there is a helpful guide:

SQL连接的直观说明