Reputation: 41
i have 3 tables
i am applying inner join on to retrieve the data from all these tables, but i am not getting any row as soon as any value inside any of the table is null can somebody tell me the correct way of doing this.
select name, subject, class
from table1
inner join table2
on table1.subjectId = table2.subjectId
inner join table3
on table1.classId = table3.classId
where studentId = 3
on studentId 3 there is no subject in table2 and hence it is not giving any result for all of the tables.
Upvotes: 0
Views: 95
Reputation: 477
use a left join.
select name, subject, class
from table1
left join table2 on table1.subjectId = table2.subjectId
left join table3 on table1.classId = table3.classId
where studentId = 3
Upvotes: 3