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 Quote Link to comment 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. Quote Link to comment 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 ? Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.