+ 3
Find value which is not present in inner join?
We have two tables one named as table_1 and other named as table_2. In table_1 we have 250 rows with one primary key and in table_2 we have 300 rows with one foreign key which is mapped with primary key of table_1. I want a output with the remaing 50 rows in table_2?
5 Réponses
+ 10
The rightmost option is your answer here:
https://i.stack.imgur.com/3bs7C.png
+ 6
Exactly... why we need SQL challenges.
+ 4
You need left join and chek for null, as in example (reference) above, or you can use subqueries. Somthing like
select * from table_2 where ffk not in (select fpk from table_1)
+ 2
This is an efficient way if your SQL engine supports the EXISTS keyword:
select * from table_2 where not exists (select 1 from table_1 where table_1.pk = table_2.fk);
+ 1
Select all from table2 and left join with table1and take what columns u want