Hello,
I am writing an SQL query. Maybe I am having a brain fart. Maybe I just don't know what I'm doing. Whatever.
Here is a generic representation of what I'm trying to accomplish.
TABLE A
~~~~~~
ID
OTHER...
TABLE B
~~~~~~
ID
FK_A
OTHER...
So A has a one to many relationship to B. I want to get all records of A that have child rows in B. So I think, OK, join. But of course this approach gives me duplicate records of table A for as many child records exist in B. I am not interested in any data in table B. Just A. Just those records that have one or many child records. No records that don't have child records.
Note, that I have accomplished this by using multiple queries, the distinct clause and temporary tables. What I really want though, is a single query.
Thoughts?
I am writing an SQL query. Maybe I am having a brain fart. Maybe I just don't know what I'm doing. Whatever.
Here is a generic representation of what I'm trying to accomplish.
TABLE A
~~~~~~
ID
OTHER...
TABLE B
~~~~~~
ID
FK_A
OTHER...
So A has a one to many relationship to B. I want to get all records of A that have child rows in B. So I think, OK, join. But of course this approach gives me duplicate records of table A for as many child records exist in B. I am not interested in any data in table B. Just A. Just those records that have one or many child records. No records that don't have child records.
Note, that I have accomplished this by using multiple queries, the distinct clause and temporary tables. What I really want though, is a single query.
Thoughts?