【发布时间】:2011-12-21 21:46:04
【问题描述】:
如何设置表 A 和 B 之间的关联,如果表 B 中存在记录,则不会显示任何内容(如内部连接反向)。 这可以使用 Exists 或 not Exists 来完成吗? cakephp 的语法是什么?
【问题讨论】:
如何设置表 A 和 B 之间的关联,如果表 B 中存在记录,则不会显示任何内容(如内部连接反向)。 这可以使用 Exists 或 not Exists 来完成吗? cakephp 的语法是什么?
【问题讨论】:
您可以使用not exists:
select * from tableA a
inner join tableB b on b.id not exists (select id from tableA where id <> b.id)
【讨论】: