Darkness Soul Posted November 17, 2006 Share Posted November 17, 2006 Yo, :)I'm with a little problem. I have two tables, tbUsers and tbMail. When I send a mail to my users (like newsletter sys), I record the Mail id and the User id into tbAux.But, we have lots of users, and our server can't send it all at once, our script works like it:select 200 users who are not at the tbAux, send, wait a little time, reexecute.This select is my problem.. It return all the users in or not in tbAux.. :(My select string:[code]SELECT DISTINCT tbUser.id , tbUser.name , tbUser.emailFROM tbUserINNER JOIN tbAuxON tbAux.id_user <> tbUser.idWHERE tbAux.id_mail = 6AND tbUser.status = 'A'AND tbUser.email LIKE '%@%.%'AND tbUser.id > 0ORDER BY tbUser.name ASCLIMIT 0 , 200[/code]I think its logical error, thank for any help.D.Soul Link to comment https://forums.phpfreaks.com/topic/27564-select-using-on-join/ Share on other sites More sharing options...
fenway Posted November 17, 2006 Share Posted November 17, 2006 You should not use inqualities in a JOIN condition, particularly <> -- it would be preferable to switch this to a LEFT JOIN... IS NULL. Link to comment https://forums.phpfreaks.com/topic/27564-select-using-on-join/#findComment-126072 Share on other sites More sharing options...
Darkness Soul Posted November 17, 2006 Author Share Posted November 17, 2006 sorry, I don't understand..left join tbAux on id_user is null ? Link to comment https://forums.phpfreaks.com/topic/27564-select-using-on-join/#findComment-126079 Share on other sites More sharing options...
fenway Posted November 17, 2006 Share Posted November 17, 2006 Try something like this (untested, in a rush):[code]SELECT DISTINCT tbUser.id , tbUser.name , tbUser.emailFROM tbUserLEFT JOIN tbAuxON tbAux.id_user = tbUser.idWHERE tbAux.id_mail = 6AND tbUser.status = 'A'AND tbUser.email LIKE '%@%.%'AND tbUser.id > 0AND tbAux.id_user IS NULLORDER BY tbUser.name ASCLIMIT 0 , 200[/code] Link to comment https://forums.phpfreaks.com/topic/27564-select-using-on-join/#findComment-126390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.