Results 1 to 4 of 4

Thread: [RESOLVED] SQL select with multiple values

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Resolved [RESOLVED] SQL select with multiple values

    Hi All,

    My table having the fields as below.


    347 111 2 15 187 6/8/2010 1:19:44 PM
    348 111 2 21 187 6/8/2010 1:19:44 PM
    349 111 2 42 187 6/8/2010 1:19:44 PM
    350 111 3 42 187 6/8/2010 1:19:44 PM
    351 111 4 42 187 6/8/2010 1:19:44 PM

    How to select the row that must contains both 2,3,4

    Thanks a lot.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: SQL select with multiple values

    Contains 2,3,4 in what field?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: SQL select with multiple values

    Thanks dee-U
    I have found the solution with the code as below

    SELECT ID

    FROM TableName

    WHERE ThirdField IN (2,3,4)

    GROUP BY ID

    HAVING COUNT(DISTINCT ThirdField) = 3
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  4. #4
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: [RESOLVED] SQL select with multiple values

    My guess is the third column :-)

    Select ThirdColumn from MyTable where ThirdColumn in (2,3,4)

    Or

    Select ThirdColumn from MyTable where ThirdColumn = 2 or ThirdColumn = 3 or ThitdColumn = 4

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