I have two tables, one of users and one of photos where each line contains the user id of the respective photo.
I want to select the user data and get the photos by the user id of the photos table.
In this way it returns me the duplicate data from the user table because the user contains several photos in the photos table.
How can I just get the user data (user table) and all photos that belong to the photos (table photo), which the user ( user_id
) contains in the photos table?
$sql = "SELECT u.id, u.username, u.genero, u.idade, u.local, u.descricao, p.user_id, p.location
FROM user AS u
INNER JOIN photos AS p
ON u.id=p.user_id
";