Brad Tilley wrote:
I should better describe the tables:
computers has 'comp_id' as its primary, unique key. users has 'user_id' as its primary, unique key. comp-user-link has two (and only two fields) that are *never* null: 'comp_id' (which must be unique), and 'user_id'
Every computer is linked to a user... the problem is some users (those who have left, or returned computers for various reasons) are still in our users table for historical purposes... we maintain a 'transfers' table to show when computers were given to users... this is why we never throw users away even after they're no longer associated with us. Does that make sense?
Anyway, I only want to show the users that currently are not linked to a computer and the linking table does not contain nulls.
Thanks.
Then you need to use the query that Victor Pendleton and Shawn Green already sent you:
SELECT users.ID, users.Name FROM users LEFT JOIN comp-user-link ON comp-user-link.user_id = users.user_id WHERE comp-user-link.user_id IS NULL
The LEFT JOIN gives you a result for every row in the first (left) table, regardless of whether or not it has a match in the second (right) table. In the case of a row with no match in the right table, you get NULLs for the right table columns. So, users who are in the users table but not the comp-user-link table will be returned by the LEFT JOIN with NULLs in the comp-user-link columns, and the WHERE clause says to only show those rows.
Michael
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]