Let's say you have table A
CREATE TABLE A (
id int,
attribute varchar(10)
)
CREATE TABLE B (
id int,
parent_id int,
attribute varchar(10)
)
parent_id is a link to the id column in A. I would like all rows from A (all columns), if B.attribute = "Test". Note that there may be multiple B records for each A, but I only want the DISTICT A. I know I could do this, but it seems like it would not be performant.
SELECT DISTINCT a.id, a.attribute
FROM A a JOIN B b ON a.id = b.parent_id
WHERE b.attribute = "Test