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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

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

ios - I get the error Property '...' not found on object of type '...' -