Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2003
    Posts
    1

    Unhappy Unanswered: 3 Table Massive Query

    I have 3 tables(1=165000 records, 2=11500 records, 3=14000 records). I am having trouble retrieving data which is duplicate in all three tables. Can anyone help? I am using both Access and SqL yet no results.
    Thanks

  2. #2
    Join Date
    Sep 2002
    Posts
    456

    Re: 3 Table Massive Query

    If structure of tables is similar too then use UNION clause to accomplish the resultset.

    dollar

    Originally posted by Angela
    I have 3 tables(1=165000 records, 2=11500 records, 3=14000 records). I am having trouble retrieving data which is duplicate in all three tables. Can anyone help? I am using both Access and SqL yet no results.
    Thanks

  3. #3
    Join Date
    Jan 2002
    Location
    USA
    Posts
    53
    Yes, you can use UNION then use distinct


    -Ljrong

  4. #4
    Join Date
    Sep 2002
    Location
    Montreal, Canada
    Posts
    224
    Provided Answers: 1

    Re: 3 Table Massive Query

    Originally posted by Angela
    I have 3 tables(1=165000 records, 2=11500 records, 3=14000 records). I am having trouble retrieving data which is duplicate in all three tables. Can anyone help? I am using both Access and SqL yet no results.
    Thanks
    Could you post your table structure (using DESCRIBE) and an example of what you try to do with example results?

  5. #5
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,

    No need of using DISTINCT, because UNION cause returns only distinct values of all tables.

    Hope this helps,
    Grofaty

    Originally posted by ljrong
    Yes, you can use UNION then use distinct


    -Ljrong

  6. #6
    Join Date
    Jan 2003
    Posts
    1,605

    Re: 3 Table Massive Query

    Hi Angela,

    What kind of data would you like to get? Would you like to get rid of duplicate data or you would like to get the data witch are duplicate on two of three tables?

    To get rid of duplicate data use:
    select c1 from t1 UNION select c1 from t2 UNION select c1 from t3

    To get duplicate data use:
    select c1 from (select c1 from t1 union all select c1 from t2 union all select c1 from t3) alias group by c1 having count(*) > 1

    Hope this helps,
    Grofaty

    Originally posted by Angela
    I have 3 tables(1=165000 records, 2=11500 records, 3=14000 records). I am having trouble retrieving data which is duplicate in all three tables. Can anyone help? I am using both Access and SqL yet no results.
    Thanks

Posting Permissions

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