Issue Building PHP / MySQL Join Query -
i having issues trying construct join query. appreciated! thanks!
i have 3 tables here. table houses our "users." identified id number. table c houses locations identified id number. table b contains connection between table , table c. uid id of user , lid id of location. user might associated multiple locations.
i need build query take id of user, find of locations user's id associated , return them.
table a
| id | name | ----------------------------- | 0 | steven | ----------------------------- | 1 | etc | -----------------------------
table b
| id | uid | lid | ------------------------------------------- | 0 | 0 | 1 | ------------------------------------------- | 1 | 1 | 1 | -------------------------------------------
table c
| id | location_name | ---------------------------------- | 0 | santa monica | ---------------------------------- | 1 | hamptons | ----------------------------------
you can try below
select a.id user_id, a.name user_name, c.location_name location tablea join tableb b on a.id = b.uid join tablec c on b.lid = c.id a.id = 0;
Comments
Post a Comment