Left Join in Mysql? -


this first table.

table1

then second 1 is

table2

now trying left join this

select t1.stackid t1 left join t2 on t1.stackid=t2.stackid 

output

output

i confused here, correct output? not supposed return 5 rows present in left side table.

it's correct output. doing left join, every record in left table dbms 'concatenate' corresponding right table record(-s) (and null, if there's no corresponding record join condition; remember, if there more 1 corresponding record - all joined - issue why you're getting not 5 records 1-st table).

the thing you're trying achieve should done either distinct modifier, i.e.

select distinct t1.stackid t1 left join t2 on t1.stackid=t2.stackid; 

more join in sql can read here.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -