Reputation: 11
I want to get remainder after dividing two tables .
Example:
table1 contains
name roll city
gran 1 mumbai
raj 2 kolkata
mahesh 3 delhi
Table 2 contains
roll
2
3
Then the output should be
name city
raj kolkata
mahesh delhi
update: I don't want to get the output after supplying column names. I want the result to come out after filtering only the one column
Upvotes: 1
Views: 7915
Reputation: 982
this should work
select name,city from table_1 where
roll in (select roll from table_2)
Upvotes: 1
Reputation: 32841
You don't need a nested SELECT
when you can just use an INNER JOIN
SELECT name, city
FROM table1
INNER JOIN table2
ON table1.roll = table2.roll
Upvotes: 1
Reputation: 55489
select name, city from table1
where roll in (select roll from table2)
Upvotes: 0