SELECT statement



hi all here is the problem is that i have 2 table in both there is a column called user_name ok.
i would like to choose the user_name rows from the 1st table which is not exists in the second table.

here is an ex. for the contents of each table.
say table (usersonline) contains:
and table (forum_users_registered) contains:
so i would like to choose (sarah from table usersonline)
my SQL code is:
SELECT onl.user_name, r.User_Name
from usersonline onl, forum_users_registered r
AND onl.user_name != r.User_Name;
and here is the result:
it displays a combination of the 2 tables which i don't need.cuz it compares the first row in table1 with each row in table2.but i'd like to compare 1st row in table1 with all rows in table2.then the 2nd row in table1 with all rows in table2. and so on.
you need a sub query
something like
select field_names, ....
from tablename
where user_name not in (select ...[your username list])

But Mysql 3.28.x does not support sub queries but 4.x does
i have MySQL 4.0.14 and it is not running there any suggestions?
You can always do this with 2 SQL's and a bit of a PHP code :)

However i think its possible to do this with joining... might take some timee to figure it out thou...
i hope that any one write me any helping code..but no one do..
i solved that and here's the solution:
SELECT distinct t1.user_name, t2.User_Name
FROM table1 t1left join table2 t2
on t1.user_name = t2.User_Name
where t2.User_Name IS NULL;
i told you joining :)
However i dindt remember the syntax...

But anyways.. :) if you want a code : ask for it... otherwise we are lasy bastards that will tell you how to do it but not gonna write the code :p