- 1
SQL join
Table projects id - pk, client_id - fk, title, url, description.. Table clients client_id - pk, name, url, Table images image_id - pk, project_id - fk, url, title I need to get all matching images from images with the same project id I came up with something that doesn't return all images, only the first match
8 Answers
+ 2
Are there multiple images for a single project? you said "images with same project Id".
If you only want the image (url) then I don't see why you are selecting projects.title and clients.name. Or did I misunderstood something?
+ 1
What query did you used?
+ 1
Images doesn't have client_id
0
SELECT projects.title, clients.name, images.url FROM projects JOIN clients ON clients.client_id = projects.client_id JOIN images ON images.project_id = projects.id;
0
Yeah, sorry about that, fixed it.
0
I want all the properties from 3 tables at the same time.
0
But your query is fine, if you want to get images for all projects
0
Akib Reza
https://www.w3schools.com/sql/sql_join_full.asp
Hope it will help you ✌