I'm currently writing an update to a script I wrote some time ago. It's a CMS of sorts, for auto dealers.

History aside, here's the issue i'm needing help with: I'm pulling data from 3 separate tables with this query:
SELECT a.v_id, a.v_date, a.v_year, a.v_make, a.v_model, a.v_cost, a.v_caption, b.make_title as v_make, c.image_title as v_image FROM vlot_listings a, vlot_makes b, vlot_images c WHERE a.v_status = 1 AND b.make_id = a.v_make AND a.v_id = c.v_id GROUP BY c.v_id ORDER BY v_date DESC

As expected, it's only pulling vehicle data that has an image. I've been racking my brain, though i'm just not certain as to how I can pull all vehicles with a v_status of 1, regardless of whether there are images or not?

v_id is the primary key for vlot_listings.
v_date is a timestamp of when the vehicle was added
v_year is the year the of the vehicle, stored as an integer
v_make is the ID that corresponds to the make_title (from vlot_makes table)
v_model is a string representing the Model (I haven't built a table of models. seems like a TON of work!)
v_cost is of course, the cost, stored as an integer

make_title is the title associated with the id v_make (from vlot_listings table)

image_title is the filename of the image stored on the server. No path.

v_status can be a 1 or a 0. 0 means it's not visible to the public while 1 means it is visible to the public.

Any ideas to point me in the right direction is greatly appreciated.

    Sounds like you want to use a left join on the vlot_images table, whereas right now you're implicitly doing an inner join on it along with the other tables.

    DeadlySin3 Ahh, thanks!!

    I was correct in my optimism that you just needed a prod in the right direction. 🙂

    NogDog That’s really all that I needed was that little nudge. I was even reading about left joins before I posted this. I’m confident I would have solved the issue without the assist, however, I know I solved it faster with your help. Much appreciated NogDog

      Write a Reply...