php - should i use LEFT JOIN all the time when obtaining the data from more than two tables? -


here below example of mysql

select a.hospital_id, a.name, a.distance, b.name, a.near_gate  hospital a, station b  a.campus='".$campus."'        , a.category='".$category."'        , a.station = b.id 

this example works though, okay use example right away, or should add word left join?

thanks in advance ~ :)

your query equivalent following:

select a.hospital_id, a.name, a.distance, b.name, a.near_gate  hospital join station b on a.station = b.id a.campus='".$campus."' , a.category='".$category."' 

it's inner join, not left join

update

actually, from table1, table2 should result in cross join. database engines smart enought figure out condition where part should used determine join condition , change inner join.


Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -