shrndegruv
Registered User.
- Local time
- Today, 04:35
- Joined
- Sep 8, 2004
- Messages
- 58
I have a query on two tables with a one to many relationship.
I would like to write a query that limits the results based on fields in both tables, AND that only returns one row, regardless of how many rows are in the "many" table of the 1-many relationship. This is not an inner join or an outer join (both can return many rows if there are more than one row in the many table).
The tricky part is if there are no rows in the many table and there is a row in the one table that meets the requirement.
Do I need an intersect or union? Do I need multiple queries?
Im thinking the first option
Select *
FROM one-table
WHERE paramaters1
UNION
Select *
FROM many-table
WHERE parameters2
The question is will this return a row in the one-table more than once?
thanx
mike
I would like to write a query that limits the results based on fields in both tables, AND that only returns one row, regardless of how many rows are in the "many" table of the 1-many relationship. This is not an inner join or an outer join (both can return many rows if there are more than one row in the many table).
The tricky part is if there are no rows in the many table and there is a row in the one table that meets the requirement.
Do I need an intersect or union? Do I need multiple queries?
Im thinking the first option
Select *
FROM one-table
WHERE paramaters1
UNION
Select *
FROM many-table
WHERE parameters2
The question is will this return a row in the one-table more than once?
thanx
mike