SELECT group_name FROM rdxls_groups JOIN rdxls_banned WHERE rdxls_groups.group_name!=rdxls_banned.data
Basically "rdxls_banned" table has the name of the banned group in a field called "data". What I'm trying to do is to get the group name from the table "rdxls_groups" which are not found in the "rdxls_banned" table.
But when I execute the above query it gives me the results I want but x3, the same group name is returned three times... Any ideas?
OK... it stopped returning lots of results but I realised the query also returns the banned group. when you join a table is it joined according to the id numbers. so if you have id 1 record in one table it get joint with id 1 record in the other table. If so how would not make it so taht id 1 record in on table gets joint with all records in the other table? thanks again for the quick reply btw
It works!!! Thanks but how does it work? Sorry and another thing, I also need to make sure, in the query, that when comparing rdxls_banned.data and rdxls_groups.group_name, rdxls_banned.data - the same record must also satisfy, rdxls_banned.type='group'. How do i do that?
Last edited by RadixDev on Tue Jul 20, 2004 6:22 pm, edited 1 time in total.
LEFT JOIN looks at the data to it's left, heh, and if it doesn't match, all fields that'd normally be set, are set to NULL. So you filter it where those rows are null.. where the tables don't match..
RadixDev wrote:It works!!! Thanks but how does it work? Sorry and another thing, I also need to make sure, in the query, that when comparing rdxls_banned.data and rdxls_groups.group_name, rdxls_banned.data - the same record must also satisfy, rdxls_banned.type='group'. How do i do that?
SELECT t1.`group_name` FROM `rdxls_groups` t1 LEFT JOIN `rdxls_banned` t2 ON t1.`group_name` = t2.`group_name` AND t2.`type` = 'group' WHERE t2.`group_name` IS NULL;
I'm sorry, I didn't notice that it was so old. I actually got to it from a list of "useful posts" and just read that it was from "March" but didn't notice the year . I apologize.