Results 1 to 4 of 4

Thread: Syntax

  1. #1
    Join Date
    Jan 2010
    Posts
    1

    Unanswered: Syntax

    I am trying to gather data that my field can be any one of 200 items.

    I was trying to use something like:
    where charge_code in ( 123, 456, 555 ) I am thinking this is an "AND" and I want it to be an "OR" .

    I wanted if charge_code if is 123 OR 456 or 555. I have over 200 entries and did not want to create 200 line compares.

    Is there a better way?

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    So....You think the IN construct is similar to AND?

    How would it be useful, if you had
    Code:
    where charge_code = 123
      and charge_code = 456
      and charge_code = 789
    IN tests for any match. Not all of them.

  3. #3
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    IN clause is an OR construct. It means that the value can be any one of the values IN your list.
    Dave

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Thomasj View Post
    I have over 200 entries and did not want to create 200 line compares.
    you don't want to list them in an IN list, either

    you want to store them in a table and then do a join

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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