Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    138
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Problem with multiple WHERE conditions

    Here is my query:

    PHP Code:
    $resultleads mysql_query("SELECT * FROM LeadTable WHERE Operator = '$CurrentOp' AND CallBackDateTime IS NULL AND (LeadDisposition IS NULL OR LeadDisposition = 'NA' OR LeadDisposition = 'LM') ORDER BY DispositionDateTime ASC, TimesDispositioned ASC, LeadType ASC") or die(mysql_error()); 
    If I remove any one of the three WHERE conditions, it works correctly. That doesn't work, I need all three...

    Tips?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,151
    Thanks
    80
    Thanked 4,557 Times in 4,521 Posts
    Never seen anything like that.

    Code:
    SELECT * FROM LeadTable 
    WHERE Operator = '$CurrentOp' 
    AND CallBackDateTime IS NULL 
    AND (LeadDisposition IS NULL OR LeadDisposition = 'NA' OR LeadDisposition = 'LM') 
    ORDER BY DispositionDateTime ASC, TimesDispositioned ASC, LeadType ASC
    Is it possible there is no record that satisfies all three AND'ed conditions???

    You could rewrite the last of those:
    Code:
    AND IFNULL(LeadDisposition,'NA") IN ('NA','LM')
    I don't see why that would matter, but worth a shot.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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