0

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?

John
  • 92
  • 7

2 Answers2

3

try this

select * from t1 where t1.Id in (select distinct Id from t2)
Amit
  • 15,217
  • 8
  • 46
  • 68
  • Just what I was looking for- added the where clause after t2 (where column = columnValue) and it worked perfectly – John Jul 18 '13 at 15:05
0

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.

logixologist
  • 3,694
  • 4
  • 28
  • 46