SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot croman's Avatar
    Join Date
    Apr 2003
    Location
    Minneapolis, MN
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select with Multiple Columns

    This is probably super basic and it is very probable that since I have not worked with SQL in a few years the answer is just escaping me. Well and maybe that it is 1am does not help. Anyways, here is the problem I am having.

    I am trying to find out of a value exists in any of multple columns.

    In this table I have ID, Name, Dist1, Dist2, Dist3

    I want to do a SELECT * FROM Table WHERE (either Dist1, Dist2 or Dist3) = Value

    So, if the Value exists in any of those columns, it returns a result.

    Any help is greatly appreciated

    Thanks

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    SELECT * FROM Table WHERE Dist1 = Value OR Dist2 = Value OR Dist3 = Value

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    SELECT * FROM Table WHERE Value IN ( Dist1, Dist2, Dist3 )

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Zealot croman's Avatar
    Join Date
    Apr 2003
    Location
    Minneapolis, MN
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much!


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
  •