Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combining table selects

Status
Not open for further replies.

simanek

Programmer
Jan 19, 2001
137
US
I want to select all the columns in two different tables that have some columns in common and some that are not in common. I would like to view all of the columns in both tables but I want to eliminate some of the records depending on what some of these 'extra' columns are equal to. Is it possible to do this?

the columns in table1:
column1, column2, column3, column4

the columns in table2:
column3, column4, column5, column6

What I'm trying to do:
SELECT * FROM table1 table2 WHERE column1=someval and column3=otherval and column6=anotherval;

But of course, that doesn't work. Any help would be greatly appreciated. Thanks. Mike
~~~~
simanek@uiuc.edu
"It's a Swingline!"
~~~~
 
The reference to column1 may be ambiguous (to the computer that is) so you can prefix it with the table it belongs to.
I think you want something like:

[tt]
SELECT * FROM table1 table2 WHERE table2.column1=someval and table1.column3=otherval and table1.column6=anotherval;
[/tt]


DjangMan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top