Results 1 to 15 of 15

Thread: SQL and AND [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Resolved SQL and AND [RESOLVED]

    hi:

    The last post we had resolve a problem with nulls and empty strings!
    Now I have annother problem with Logic Operator "AND":

    this is the problem:

    Example:
    This is the fields I have in the Database Access:

    Code:
    Raca          dt_morte1       dt_morte2       dt_morte3
    especie          Goro                          Goro   
    especie           car              Goro
    Now I want extract the fields don't have nulls or empty strings where the "Raca" be "especie" and the dt_morte1,dt_morte2,dt_morte3="Goro"

    the code:

    Code:
    SQL = "select Sum(IIF(dt_morte1 Is Null or dt_morte1='', 0, 1) ) as total1,Sum(IIF(dt_morte2 Is Null or dt_morte2='', 0, 1) ) as total2,Sum(IIF(dt_morte3 Is Null or dt_morte3='', 0, 1) ) as total3, from " & ano
    SQL = SQL & " WHERE Raca = '" & especie & "'" AND dt_morte1 = '" & Goro  & "' AND dt_morte2 = '" & Goro  & "'  AND dt_morte3 = '" & Goro  & "'
    the problem is:

    With the "AND dt_morte2 = '" & Goro & "' AND dt_morte3 = '" & Goro & "' " the code return a wrong value.He return's "0".


    Only with the first "AND dt_morte1 = '" & Goro &'" the code return the right value "1"

    Something wrong with the expression?Why the code just return the right value with one "AND"?

    Thanks
    Last edited by sacramento; Jun 5th, 2005 at 12:47 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width