quasi random (kaolinfire) wrote,
quasi random

Is it just because I'm sick?

I am sick. It is unpleasant.


There has GOT to be an easier way to do this--doesn't there?

I just spent _two hours_ on this, so I don't know. Trying to get the id associated with the minimum sort order of each set of images for a given set of "stock number"s.

SELECT min(i1.id) as id, i1.stock_number, i1.sort FROM inv_image_groups i1, (SELECT max(sort) as sort, stock_number FROM inv_image_groups GROUP BY stock_number) as i2 WHERE i1.stock_number IN (SELECT distinct stock_number from inv_image_groups) AND i1.stock_number = i2.stock_number and i2.sort = i1.sort GROUP BY i1.stock_number;

Essentially, there can be any number of images associated with a given vehicle, each with a sort order so we know how to display them. When listing a bunch of vehicles, I want to pull each image with the lowest sort order for each vehicle, to just show that one thumbnail.

Tags: handbrewed, overworked, sick, sql, valencia acura

  • who wants to write this?

    "A wakeup call for budding sociopaths" or "bitter red pills for the resistant"— Okay, start here if you haven't: RT @ evilrooster: Theory:…

  • A year of poetry and fiction....

    It doesn't feel like much (I haven't been writing, mostly), and I've not been submitting like I need to, but somehow I managed to succeed…

  • a day in the life of lives...

    I know this isn't Facebook, so I shouldn't post a link and run. So, umm. The link: Michael Lewis profiles Barack Obama. It's a day-in-the-life, but…

  • Post a new comment


    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.