Sql-server – how to take output from second table by joining in SQL

MySQLsql server

table 1                              table 2

id  Name  value                    id  status
1  a      1000                     1   open
2  b      2000                     2   closed
3  c      3000                     3   closed
4  d      4000                     4   open
5  e      5000                     5   open

I want the output as the names which are closed. What will be the possible solutions?

Best Answer

Try Something like if you wish to use joins :

 select name from table1 t1 inner join table2 t1 on t1.id=t2.id where t2.status = 'closed'; 

or

select name from table1 t1, table2 t2 where t1.id=t2.id and t2.status = 'closed';