Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query for parents with children only 1

Status
Not open for further replies.

klange

Programmer
Oct 17, 2002
6
US
I need to write an SQL statement for ACCESS for a database with two tables with a one to many relationship I need a query that returns only parent records that have children and return the parent record only once, not once for each child. My query keeps returning the parent once for each child.

 
You should be able to do that with a subquery in the where clause. The subquery would group on the key that joins the 2 tables.

select id, fld1, fld2, etc from parenttable
where id IN
(select id from childtable group by id)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top