I have a table that has two columns. One is image_id and one is image_name. Like this
image_id | image_name
--------------------
1 | terrier.jpg
2 | schnauzer.jpg
3 | beagle.jpg
And I have another table like this:
item | image_1 | image_2
------------------------------------
Friendly Dogs | 1 | 2
Loyal Dogs | 2 | 3
The first table let’s call images and the second table is dogs.
I tried the following SQL but it didn’t work:
SELECT * FROM dogs INNER JOIN images ON images.image_id = dogs.image_1 AND INNER JOIN images ON images_image_id = dogs.image_2
But this errors out. I’m missing somethings where I can specify names some kind of alias or something for image_name so it doesn’t overlap in the query.
What I want is an array that has image_1 and image_2 in it rather than image_name.
Can someone help out? Thanks.
I want in the array two arrays or objects:
[item] => Friendly Dogs
[image_1] => terrier.jpg
[image_2] => schnauzer.jpg
and
[item] => Loyal Dogs
[image_1] => schnauzer.jpg
[image_2] => beagle.jpg
You can JOIN a table multiple times: