php - using inner join and 4 tables is that possible -


i have members table contain 3 field foreign key 3 tables

so want join between them possible ??

member table :

  • governorate
  • district
  • village

each field foreign key table

governorate table :

  • governorate_id
  • governorat_name

district table :

  • district_id
  • district_name

village table :

  • id
  • village_name

can in 1 query ????

yes can.

select  b.governorat_name,         c.district_name,         d.village_name    member         inner join governorate b             on a.governorate = b.governorate_id         inner join district c             on a.district = c.district_id         inner join village d             on a.village = d.id 

to further gain more knowledge joins, kindly visit link below:

the query uses inner join in results should have atleast 1 matching record on every parent table (governorate, district, village).

when columns nullable , want show records on table member table whether has no matching record on parent table, use left join instead if inner join.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -