×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hello, I need help with my query. I

Hello, I need help with my query. I

Hello, I need help with my query. I

(OP)
Hello, I need help with my query. I built 2 tables: Table 1: sub account number, account name, amount paid (Record one: abc, Tree, 100; Record two: abc, Tree, 200) and Table 2: account number, sub account number, account name (Record one: 1122, abc, Tree; Record Two: 3344, acb, Tree). I joined them by sub account number and account name. I was looking to get the following answer: Account Number; Sub Account Number; Account Name; Amount;
1122 abc Tree 100
3344 abc Tree 200
but I got additional records that I do not need.
Account Number; Sub Account Number; Account Name; Amount;
3344 abc Tree 100
1122 abc Tree 100
3344 abc Tree 200
1122 abc Tree 200
How can I get read of theses additional records?
Thank you for your responses. smile

RE: Hello, I need help with my query. I

Can you go to sql view and post your actual SQL. If I understand correctly you may have not joined the tables and actually created a cartesian products. Two tables without a join give you each record in table one joined to each record in table two

RE: Hello, I need help with my query. I

(OP)
Hello MajP,
Thank you for your response. The SQL for my query is as follows:
SELECT Table2.[Account Number], Table1.[Sub Account Number], Table1.[Account Name], Table1.Amount
FROM Table1 LEFT JOIN Table2 ON (Table1.[Sub Account Number] = Table2.[Sub account number]) AND (Table1.[Account Name] = Table2.[Account Name]);

This is a mock up query. But it is an accurate reproduction of my issue. The tables are imported from 2 different sources and missing any/all unique values or anything that I could potentially use as a unique value. I have to come up with a work around.
Thank you again for your help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close