Ive got this to work, but it is a serious pain.<BR><BR>Select * from table1,table2 Where (table1.key=mykey) Or (table2.key=mykey)<BR><BR>The problem is that both tables have the same primary key name. I want everything from both tables where the One key matches in both tables. Is there an easier way?
I don't get it. This looks (I'll admit I'm NOT a guru), like it will get me everything where the two tables have the same id/key Not where what I'm looking for in both tables exists. Am I totally missing the boat here?
I might not understand what your saying but... <BR><BR>1.<BR>SELECT * FROM Table1 INNER JOIN Table2 ON Table.Key = Table2.Key<BR><BR>This will select ONLY those records with the same key THAT EXIST IN BOTH TABLES<BR><BR>2.<BR>SELECT * FROM Table1 LEFT JOIN Table2 ON Table.Key = Table2.Key<BR><BR>This will select ALL RECORDS from Table1 and ONLY those records in table2 where the joined fields Are equal.<BR><BR>3.<BR>SELECT * FROM Table1 RIGHT JOIN Table2 ON Table.Key = Table2.Key<BR><BR>This will select ALL RECORDS from Table2 and only those records in table1 where the joined fields Are equal.<BR><BR>Using the LEFT and RIGHT JOINS will return all records from one table and only those that match from the other. Records that don't have a match in the other table will return fields with null values...<BR><BR>Make sense?<BR>
I think this is going in the right direction: I'll give you an example:<BR><BR>t1 contains user information for year 2000<BR>t2 contains user information for year 2001<BR><BR>I want to request all records from both tables for UserA (ID:1):<BR>I've been doing this ugly thing:<BR>SELECT * From t1,t2 Where (t1.PKey = UserID) OR (t2.PKey = UserID);<BR><BR>The keys (all fields actually) are named the same in both tables. Does this make any more sense?