|
-
Jun 8th, 2010, 01:04 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Jun 8th, 2010, 03:16 AM
#2
Re: SQL select with multiple values
Contains 2,3,4 in what field?
-
Jun 8th, 2010, 04:34 AM
#3
Thread Starter
Hyperactive Member
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.
-
Jun 8th, 2010, 04:34 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|