I'm not very competent with MySQL joins so I would appreciate some help.
I have two tables. Lets call them X
and Y
.
X
is the main table, however I want to get one column of data from table Y
where the site_id
in table X
corresponds to the site_id
in table Y
.
Example scheme for table X
: id, site_id, notes
Example scheme for table Y
: id, site_id, name
I would like to then create a query to have id, site_id, notes, name
where name
corresponds to the site_id
Can anyone help?
Thanks
SELECT
X.id,
X.site_id,
X.notes,
Y.name
FROM
X
LEFT JOIN Y ON X.site_id = Y.site_id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.