php - Query which involves 4 tables, inner join? -


i developing php aplication, , need query involves 4 tables. tables like:

news {news_pk, user, description, building_pk} building {building_pk, area_pk, description} area {area_pk,state_pk} states {state_pk, name} 

i show results filtered state name (or think same state_pk). show news state.

i not using mysql often, in app doing several queries , not sure if inner join solution.

which query effective show news state?

you should use following query join tables:

mysql_query("select a.news_pk,a.user.a.description,a.buiding_pk,b.building_pk,b.area_pk,b.description,c.area_pk,c.state_pk,d.state_pk,d.name news a,buiding b,area c,states d a.buiding_pk=b.building_pk , b.area_pk=c.area_pk , c.state_pk=d.state_pk"); 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -