Query type problem...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Jacobs

    Query type problem...

    I'm having trouble getting my head round the logic of something I'm trying
    to do:

    We have a table with lots of rows. Each row has a column for 'range' and a
    column for 'style'. So, it might look something like this:

    Range A | Style One | Colour One
    Range A | Style One | Colour Two
    Range A | Style One | Colour Three
    Range A | Style One | Colour Four

    The way that the database is constructed is not great but it's what I've got
    to work with!

    There are many ranges
    Each range contains several styles
    Each style is available in several colours

    What I want to do is for the visitor to click on a range. The page then
    shows all the styles in that range and ONE colour (Doesn't matter which,
    just the first one it finds)

    They then click on a style and are shown a page where they can choose the
    colour from a thumbnail. This bit is done, it's the step before that I'm
    stuck on.

    Any help would gratefully received.

    Andy



  • Dan Stumpus

    #2
    Re: Query type problem...


    "Andy Jacobs" <andy@redcatmed ia.net> wrote
    [color=blue]
    > We have a table with lots of rows. Each row has a column for 'range' and
    > a
    > column for 'style'. So, it might look something like this:
    >
    > Range A | Style One | Colour One
    > Range A | Style One | Colour Two
    > Range A | Style One | Colour Three
    > Range A | Style One | Colour Four
    >
    > There are many ranges
    > Each range contains several styles
    > Each style is available in several colours
    >
    > What I want to do is for the visitor to click on a range. The page then
    > shows all the styles in that range and ONE colour (Doesn't matter which,
    > just the first one it finds)[/color]

    Try:
    select range, style, min(colour) as sample_color
    from inventory
    group by range, style

    This will give you the first color (alphabetic). (Untested)

    -- Dan


    Comment

    Working...