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

Mysql query - two tables

Status
Not open for further replies.

dle46163

IS-IT--Management
Jul 9, 2004
81
US
Hi All,

I have two tables: Table_a and Table_b. They both have a username field. I want to pull all the usernames in Table_A as long as they are not listed in Table_b. My query for Table_a by itself looks like this:

$query = "SELECT username FROM Table_a
WHERE user_type='{$_SESSION['user_type']}'
ORDER by username";

Can I tell it to exclude usernames which are also found in Table_b, all in the same query? Thanks so much!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top