SQL query help required...

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

    #1

    SQL query help required...

    I would really appreciate some assistance with a query I need to make
    on my mysql db.

    I have three tables as follows:
    Orders order_id, order_date
    Pin_Orders orders_pin_id, orders_id(from the orders table),
    card_id(from the cards table)
    Cards card_id, card_name

    I would like to select the orders.order_id , cards.card_name for all
    the orders that were made on a particular date.

    I know I need to use a left join but I'm not sure how to construct
    this since there are three tables which need to be used.

    Thanks, in advance.

    Nagsy
  • Good Man

    #2
    Re: SQL query help required...

    mantas44@hotmai l.com (Manny) wrote in
    news:3e1d3163.0 501230954.2c20e b4c@posting.goo gle.com:
    [color=blue]
    > I would really appreciate some assistance with a query I need to make
    > on my mysql db.
    >
    > I have three tables as follows:
    > Orders order_id, order_date
    > Pin_Orders orders_pin_id, orders_id(from the orders table),
    > card_id(from the cards table)
    > Cards card_id, card_name
    >
    > I would like to select the orders.order_id , cards.card_name for all
    > the orders that were made on a particular date.
    >
    > I know I need to use a left join but I'm not sure how to construct
    > this since there are three tables which need to be used.[/color]


    Hmmm, I think I would also throw the order_id (or orders_pin_id) into the
    Cards table, but this should work...


    SELECT o.order_id,c.ca rd_name FROM Orders o, Cards c, Pin_Orders p WHERE
    o.order_id=p.or ders_id AND c.card_id=p.car d_id AND
    o.order_date='w hateveryourdate is'




    Comment

    Working...