Reputation: 93
I have two tables and I want to join them to get the desired output. Say the 1st table (seat1) is
and the 2nd table (collegestudents) is
The desired output is
I have tried the below code. But it fails to give the desired result.
$rde2=mysqli_query($con, "select * from seat1 s
left JOIN collegestudents c ON c.Roll = s.Roll
");
Any help please.
Upvotes: 0
Views: 39
Reputation: 222482
You want a left join
. Your query looks fine, but you would need not to use select *
, and instead explictly list the columns that you want to select, using table prefixes. Otherwise, since you have a Roll
column in both tables, a name clashes will happen, that your application apparently does not handle well.
select
s.Roll,
c.Name,
s.Subject
from seat1 s
left join collegestudents c on c.Roll = s.Roll
Upvotes: 3