Re: Whats wrong with this query

Originally Posted by
chrislynch8
Hi,
I have the following query I am running to the SugarCRM.
PHP Code:
SELECT * FROM `accounts` `a` INNER JOIN `accounts_cstm` `b` ON `a`.`id` = `b`.`id_c` WHERE `b`.`pr_area_code_c` = '333' AND (`a`.`name` != 'CLIENT ACCOUNT NUMBERS' OR `a`.`name` != 'CLIENT AVAILABLE')
I want all the 333 Account where the Name IS NOT CLIENT ACCOUNT NUMEBRS or CLIENT AVAILABLE, but the results include CLIENT AVAILABLE...
Am I using the AND and OR incorrectly
Rgds
Chris
if i'm understanding you correctly you want
WHERE
`b`.`pr_area_code_c` = '333'
AND `a`.`name`not in ( 'CLIENT ACCOUNT NUMBERS' , 'CLIENT AVAILABLE')
Mike Solomon
Development Manager
Ivy Ltd
www.ivy.ltd.uk]www.ivy.ltd.uk
php version 5.2.6
MySql 5.1.59
Bookmarks