Answer the question
In order to leave comments, you need to log in
How to write a one-to-many SQL query?
Good evening, there are 2 tables - company (id, title, descr), company_images (id, company_id, image).
The site displays companies and their photos in each company card.
I can select all the photos of a certain company individually, but the problem is that I need to display several companies on the page at once and several photos of each company (cycle in a cycle). How to do it correctly using php? At the moment, I'm uploading photos using ajax, after all the companies have uploaded.
Answer the question
In order to leave comments, you need to log in
Decide how you will filter companies. And then join this list with the image table (one query) or make a separate query for each company.
SELECT * FROM company_images WHERE company_id IN (айди компаний через запятую)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question