#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Norwich, UK
    Posts
    84
    Rep Power
    13

    Question Help in building advanced query


    Hi all,

    I need to build an SQL query invloving 3 tables and I'm a bit stuck (it's that time of day).

    I have the following three tables:

    Mat2Prod, with columns "Code" and "Product"
    Mat2Age, with colums "Code" and "Age"
    Mat, with "Code" (and others)

    I need to find all rows in Mat where Product = $var1 and Age = $var2, with both of the $vars given.

    I've done joins before with 2 tables but with three my head starts hurting. Any help appreciated!
    Yours,
    Frank Reding, IconoclastDesign.co.uk.
  2. #2
  3. Big Endian
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2001
    Location
    Fly-over country
    Posts
    1,172
    Rep Power
    30
    SELECT a.*, b.*, c.*
    FROM Mat2Prod a, Mat2Age b, Mat c
    WHERE a.Code = b.Code
    AND a.Code = c.Code
    AND a.Product = $var1
    AND b.Age = $var2
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Norwich, UK
    Posts
    84
    Rep Power
    13

    Query


    Many thanks!
    Yours,
    Frank Reding, IconoclastDesign.co.uk.

IMN logo majestic logo threadwatch logo seochat tools logo