Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Question Unanswered: pls help with outer join for multiple tables

    Can anyone help?
    im new at this and im trying to join 3 tables: a,b,c
    i used this query

    SELECT a.name, SUM(b.quantity)
    FROM a
    LEFT OUTER JOIN b ON (a.id = b.id)
    LEFT OUTER JOIN c ON (c.cid = b.cid AND c.buyer = 1)
    WHERE a.typeid =3
    GROUP BY a.name
    ;

    but the problem is, it doesnt seem to process the part where c.customer = 1 in the query, so the column quantity becomes the sum for all buyers. How do I change this to limit it to buyer = 1?

  2. #2
    Join Date
    Mar 2004
    Posts
    110
    SELECT * FROM
    (select * from tableA) a
    full outer join
    (Select * from tableB) b
    on a.<columname>=b.<columname>
    full outer join
    (select * from tableC) c
    on a.<columnname>=c.<columname>

    This would join 3 tables together.

    I dont think u can use aggregate functions in a subselect in joins tho so you would have to get around that.

    If you post your code, i could give it a shot if you want.

    -ed
    A noobie user.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •