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?
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