Skip to content Skip to sidebar Skip to footer

Select Data (join?) From Only One Table Using An Id From Another Table

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 da

Solution 1:

try this

select*from t1 where t1.Id in (selectdistinct Id from t2)

Solution 2:

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.

Post a Comment for "Select Data (join?) From Only One Table Using An Id From Another Table"