Query I can't crack

F

Francesca

Hello, I have a database with a table of Parents and a separate table of
Children, that are related.



Some parents have many children



I want to be able to delete the parents who no longer have any children
under 4. So that when I run the query, it calculates their current ages and
removes the records for parents who have NO under 4s.



If each parent only had 1 child - no problem, but how can I get it to take
into account that the parent may have many children, and therefore may
appear many times in the query that I've set up?



HELP!



Thanks
 
J

John Spencer (MVP)

One method, take a look at an EXISTS clause.

SELECT Parents.*
FROM Parents
WHERE NOT Exists (SELECT * FROM Children WHERE Age < 4)
 
J

John Spencer (MVP)

I'm sorry but I thought you said you wanted the parent record if they didn't
have at least one kid under four. Was my understanding incorrect?

Can you post the SQL statement you are trying to use and perhaps restate what
you are trying to accomplish?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top