PDA

Click to See Complete Forum and Search --> : SQL - Using Two Different Tables ??


omarswan
Dec 29th, 1999, 04:36 PM
What would be the correct SQL syntax for the following:

example : I have two tabeles
1. Baset_Ball_Players
2. Students

in the table Baset_Ball_Players there is a field called Player_Name and in Students there is a field called Student_Name.

How could I do a search to find all the matches where Player_Name = Student_Name.

Just like finding the Names that are similar in the two tables.

Another question, is this possible with two seperate database files??


------------------
OmarSwan

omarswan@yahoo.com

http://omarswan.da.ru/

"Jesus is Lord"

Mark Sreeves
Dec 29th, 1999, 04:43 PM
Like this:

SELECT Baset_Ball_Players.Name
FROM Baset_Ball_Players INNER JOIN Students ON Baset_Ball_Players.Name = Students.Name;

Not sure about using 2 databases
What you could do though is put a link in one database to the 2nd one and then treat it as one database.


------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company

omarswan
Dec 29th, 1999, 04:50 PM
Thanks Alot Mark

------------------
OmarSwan

omarswan@yahoo.com

http://omarswan.da.ru/

"Jesus is Lord"

Clunietp
Dec 29th, 1999, 09:20 PM
For two separate database tables, I believe you will have to use the ADO SHAPE command to relate tables that are not in the same database.

JHausmann
Dec 30th, 1999, 02:24 AM
Depending on the size of your tables and what you want to find, it might be more efficient to use a sub-query.

such as

SELECT Name
FROM Baset_Ball_Players
where Name in (select distinct(Name) from students)