php - MySQL Join or Nest Loop -
i have table called workshops, , table called workshop_parts.
each row in workshop_parts holds parent id references parent workshop, along various other data part.
i trying figure out efficient way retrieve , display data on website.
i want list workshop information , of parts below.
with know right loop through workshops , have nested loop loops through parts.
is there way might use join data in 1 fell swoop, or nested loop best solution?
as per post actual join:
sql left join vs multiple tables on line?
select ws.name ws_name, part.name part_name, part.qty part_quantity workshop ws left join workshop_parts parts on (ws.id = parts.workshop_id);
left join anywhere workshop id exists leave out parts have no matching workshop.
inner join workshops , parts have match (workshops without parts not show, nor parts without workshops)
right join workshop parts , other parts if have no workshop.
edit here's best way i've found think it: http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html
Comments
Post a Comment