Zend 选择不在
我有两个包含相关数据的表,我想从一个表中选择另一个表中不存在的所有记录,再加上相关表上的一些其他条件,如下所示(123 仅用于说明目的):
TABLE A
ID
SOMETHING
TABLE B
TABLE_A_ID
TABLE_C_ID
SOMETHING
我的查询,直接针对数据运行,如下所示
SELECT A.SOMETHING
FROM A
WHERE A.ID NOT IN (
SELECT
B.TABLE_A_ID AS ID
FROM B
WHERE TABLE_C_ID = 123
);
我如何在 Zend 中运行它?
I have two tables with related data, and I want to select all the records from one table which do not exist in the other table, plus some other criteria on the related table, as follows (123 is just for illustration purposes):
TABLE A
ID
SOMETHING
TABLE B
TABLE_A_ID
TABLE_C_ID
SOMETHING
My query, run directly against the data, would be as follows
SELECT A.SOMETHING
FROM A
WHERE A.ID NOT IN (
SELECT
B.TABLE_A_ID AS ID
FROM B
WHERE TABLE_C_ID = 123
);
How can I run this in Zend?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
$db->query()
运行直接sql;你的只是:编辑:要回答这是否可以使用对象表示法来完成,是:
给出
You can run direct sql, using
$db->query()
; yours would simply be:EDIT: To answer whether this can be done with the object notation, yes:
gives