tacmaf — 2011-10-28T06:21:56-04:00 — #1
I'm not great with joins but I'm trying to select each individual entry from one table and all linked images from another like so:
$q = "SELECT
ci.carID = c.carID
i.imageID = ci.imageID
Problem is, each car is being selected multiple times. If there are 3 images, the car is shown 3 times.
Where am I going wrong? I've tried INNER JOIN but had no luck.
tacmaf — 2011-10-28T06:36:17-04:00 — #2
Ah, got it with GROUP BY ci.carID
guido2004 — 2011-10-28T06:49:40-04:00 — #3
You are not going wrong. There are three images, you get three rows. Of course, the data from the cars table is duplicated in each row. You'll have to handle that in your PHP script.
Really? But now you only get one image, don't you?
tacmaf — 2011-10-28T06:53:25-04:00 — #4
Yeh. I wanted just one image. It's for a jquery slider on the homepage showing new arrivals, so any image just to link to the page. Sorry I've just read my first post and realised I got it the wrong way round. All cars, one image for each.