0

i was wondering if you could help me construct a query here

What i have is 2 Tables:

Posts and Images

Every entery in Images has a row called "post_assoc", which is set to the ID of a entery in the "Posts" Table, i want to select all Posts enteries that do not have a image entery pointing to them, is this possible without any server side script sorting ?

Feel free to ask if you need elaboration

2 Answers 2

1

Just run this query in your management software. And the result will be all posts without images.

SELECT * FROM Posts WHERE ID NOT IN ( SELECT post_assoc FROM Images )
Sign up to request clarification or add additional context in comments.

2 Comments

Ty very much, i did not realise the query could be that simple
@JohnDOe - That's the power of SQL, when you know how to use it.
1
select * from Posts P left join Images I on (I.post_assoc = P.id) where I.post_assoc is null

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.