1
I got a question about Many-to-Many relationship and I hope I’m not asking a repeated question, but I haven’t found the solution to my doubt in any corner.
I happen to have a table of images, a table of papers and a table of relationship that makes a many-to-many relationship between the first two.
Each job can have several images related to it. So I did a query as follows:
select jobs.*, f1.file_name, f2.file_name
from jobs
left JOIN photos_per_job p ON p.job_id = jobs.id
left JOIN fotos f1 on p.photo_id = f1.id
inner join fotos f2 on jobs.foto_capa = f2.id
And I got the result below:
My problem right now is organizing that information in the view. If you notice well the work that has three photos repeats in the result three times, but when I go to show the work to the user I will show one job at a time and each job will have its series of photos.
Is there any way to organize the result in a way that facilitates my loop in the view or to organize it better I need to work the loop itself?
Could you post how these three tables are done separately? It would be easier to understand. Where do these images come from?
– Fleuquer Lima
How this should be presented?
– Marco Souza