MySQL query in products system

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

    #1

    MySQL query in products system

    Hi there

    I have a products site with a mysql backend.
    I have two tables:
    1 with series,
    1 with products belonging to certain series.

    Series looks like:
    - id
    - kind
    - active
    - name

    Products looks like:
    - id
    - series_id
    - name

    Since i'm kind of a newbie, i can't figure out the
    following:
    I need the query to get all product-information on products that are
    in a series where 'series.Active = 1' and 'series.kind = 543' (e.g.
    543)
    Products have to be limited (e.g. 20)
    output sort of has to be:

    series.name - products.name - products.id

    I hope this is enough information.

    Thanks!

    Frizzle.

  • Dave

    #2
    Re: MySQL query in products system

    frizzle (phpfrizzle@gma il.com) decided we needed to hear...[color=blue]
    > Hi there
    >
    > I have a products site with a mysql backend.
    > I have two tables:
    > 1 with series,
    > 1 with products belonging to certain series.
    >
    > Series looks like:
    > - id
    > - kind
    > - active
    > - name
    >
    > Products looks like:
    > - id
    > - series_id
    > - name
    >
    > Since i'm kind of a newbie, i can't figure out the
    > following:
    > I need the query to get all product-information on products that are
    > in a series where 'series.Active = 1' and 'series.kind = 543' (e.g.
    > 543)
    > Products have to be limited (e.g. 20)
    > output sort of has to be:
    >
    > series.name - products.name - products.id
    >
    > I hope this is enough information.
    >
    > Thanks!
    >
    > Frizzle.[/color]

    You pretty much defined the query yourself already...

    select s.name, p.name, p.id
    from series s, products p
    where s.active = 1 and s.kind = 543 and s.id = p.series_id
    order by s.name, p.name
    limit 20

    Remove/change the order by as required.
    --
    Dave <dave@REMOVEbun dook.com>
    (Remove REMOVE for email address)

    Comment

    • frizzle

      #3
      Re: MySQL query in products system

      Great!
      Thanks a bunch!!!!

      Greetings Frizzle!
      (lots to learn :) )

      Comment

      Working...