I have two tables.
One contains:
id, album name, description, etc...
Another contains:
id, album id, photo
I want to get album details and its photos through album id
?
How can I achieve this?
Can I use left join?
Assuming your tables are called Albums
and Photos
:
SELECT Albums.*, Photos.Photo
FROM Albums
LEFT JOIN Photos
ON Albums.id=Photos.album_id
WHERE Albums.id=42
select a.id, a.album_name ..., b.photo
from albums a
left join OtherTable b on a.id = b.album_id
SELECT *
FROM album a JOIN photo p
ON a.id=p.album_id
WHERE a.id= 11
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.