Results 1 to 2 of 2

Thread: Whats wrong with this query

  1. #1
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Whats wrong with this query

    Hi,

    I have the following query I am running to the SugarCRM.

    PHP Code:
    SELECT FROM `accounts` `aINNER JOIN `accounts_cstm` `bON `a`.`id` = `b`.`id_cWHERE `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
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  2. #2
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Whats wrong with this query

    Quote Originally Posted by chrislynch8 View Post
    Hi,

    I have the following query I am running to the SugarCRM.

    PHP Code:
    SELECT FROM `accounts` `aINNER JOIN `accounts_cstm` `bON `a`.`id` = `b`.`id_cWHERE `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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. list view generated wrong query
    By madhrishi in forum Help
    Replies: 5
    Last Post: 2011-12-27, 09:00 PM
  2. Whats wrong with the themes (css)?
    By chris.kojak in forum Installation and Upgrade Help
    Replies: 11
    Last Post: 2011-09-05, 08:02 AM
  3. Replies: 0
    Last Post: 2008-01-16, 08:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •