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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying from 2 Tables!!! 1

Status
Not open for further replies.

pete321

Technical User
Feb 18, 2004
4
US
i'm pretty knew at MySQL. i'm using PHP to access the database.

Here's my problem!:

i have two databases...let's call them DB and REG).
- DB contains ALL my records with a unique ID.
- REG contains ONLY the records who have Registered and can be linked to DB with the ID key.

i want to write the following query:
*** Select ALL records from DB that are NOT in REG. ***

i can do it by querying each ID from DB and searching for it on REG, but i was wondering if there's a one shot statement?!

Thanx!!!
 
Are these two databases or two tables or two tables in different databases?


But it can be done. Use a LEFT JOIN.

Something like:

SELECT
*
from
<REG_tablename>
LEFT JOIN
<DB_tablename>
on
<REG_column_matching_DB_column> = <DB_column_matching_REG_column>
WHERE
<DB_column_matching_REG_column> is null


Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top