$sql = "SELECT * FROM `posts` WHERE
`posts`.`post_id` NOT EXISTS (SELECT `post_id` FROM `scene`)";
$sql = "SELECT post_id FROM `posts` WHERE NOT EXISTS (SELECT `post_id` FROM `scene` WHERE 1)";
The first query does not work, this is what I need to work to deliver the results.
The second query works, but returns post_id’s and not * as I wanted in the first query.
I could work from these querying every post id, to get the data required, but would involve a lot of more in database.
Sorry for short post, but running out. Any help appreciated.
in order to verify that something is NOT IN a list, you pretty much have to compare every item in the list, right?
this is not a big deal if the list is a collection of hardcoded literal values (constants), but if the list is a subquery, it means all the rows that the subquery returns need to be checked individually for each row of the outer query
however, a NOT EXISTS will typically need to do only one retrieval (because it’s typically a correlated subquery), so as soon as it retrieves a single row, it can stop retrieving