Using and & or in the same query

  • I'm having trouble getting this to return the correct result.

    It returns any and all rows that match the OR conditions

    SELECT * FROM tableA

    WHERE

    FullName = 1

    OR MailingAddress = 1

    OR Phone = 1

    OR Fax = 1

    OR Email = 1

    AND ListingID = 10

    I understand why it returns the other rows, but I cannot figure out how to only return the desired row.

    Any help would be appreciated

    Thanks in advance

    Rick

     

  • is your conditions :

    - ListingID equal to 10

    - FullName = 1 OR MailingAddress = 1 OR Phone = 1 OR Fax = 1 OR Email = 1

    then the OR should be place in '(' and ')'

    SELECT * FROM tableA

    WHERE ( FullName = 1

    OR MailingAddress = 1

    OR Phone = 1

    OR Fax = 1

    OR Email = 1

    )

    AND ListingID = 10

  • KH,

    Thanks for the answer,

    I'll know for next time as I should be using some more of these down the road

     

    Thanks again

    Rick

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply