php - mysql select where left join syntax -


i have problem. have 2 database tables.

table 1 people:

+----------+--------------+ |  id      | name         |  +----------+--------------+ | 1        | johanalj     |  | 2        | hjgjhggjh    |  +----------+--------------+   

table 2 images of people:

+----------+--------------+----------------+ |  id      | url          | people_id      | +----------+--------------+----------------+ | 1        | 3765345.png  | 1              | | 2        | 87e58974.png | 1              | +----------+--------------+----------------+   

now want select person id 1 table 1 , pictures table 2 have people_id 1.

i tried left join in combination cant work

$sql = "select * people p left join images  on  i.people_id = p.id id = '1'"; 

but no result massage. doing wrong?

there error(ambiguous column id). both tables have id column. need add table alias id. try -

$sql = "select * people p left join images  on  i.people_id = p.id p.id = '1'"; 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -