By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Retrieve columns in multiple table where some columns are in both tables

P: 2
I want retrieve columns x,y,z. Where x and y are in both tables A and B but z is only in table B. Any ideas? I keep getting x and y are ambiguous.
Feb 21 '14 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 10K+
P: 12,349
You need to show us your code.

But that error means it doesn't know which x and which y you want. You need to qualify the table.
Feb 21 '14 #2

P: 2
The code is simple
SELECT x,y,z
I tried UNION but that does not work since the data is too different.
Feb 24 '14 #3

Expert Mod 10K+
P: 12,349
The problem is basically what I described in my first post. You need to qualify your tables. It doesn't know which table you want the x and y from. And if you want it from both tables, you need the include them twice, each qualified for the tables.

Also, you're doing a cartesian join, are you sure you want to do that? that will multiply every row from one table with every row from the other table. You need to join the table on the key field to prevent that.

If however you are looking to append the two separate sets of records together, then you need to use a UNION. You said it doesn't work because the data is too different. All you need to do then is make it the same by converting the data.
Feb 24 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.