Reputation: 92
I have two tables, that we'll call t1 and t2. I want to select the data in t1 that has a certain ID that I can only find using a where clause in t2. I don't want to select the data in t2 (many duplicate column names with different data) so how do I do that?
Upvotes: 0
Views: 99
Reputation: 3834
Another approach is to join the tables
SELECT * FROM t1
JOIN t2 on t1.id = t2.id
You are joining them on a specific ID common between the 2 tables.
Upvotes: 0
Reputation: 15387
try this
select * from t1 where t1.Id in (select distinct Id from t2)
Upvotes: 3