tags:

views:

66

answers:

4

hi, i have write an Query where the table name is student has columns, class, names, Language

now i need to write an single query where

class='10', names ="kiran, manju, ram , peter", Language='english'

how do I write a Query where one column wil have multiple values?

Looking frwd for solution

thank you

+5  A: 

Use the "IN" Keyword

SELECT * FROM students 
WHERE class='10'
AND Names IN ('kiran', 'manju', 'ram' , 'peter')
AND Language = 'english'
David
better than mine
Nick Spiers
A: 
SELECT * FROM student 
WHERE class = 10 
AND language = 'english' 
AND (names = 'kiran' OR names = 'manju' OR names = 'ram' OR names = 'peter')
Nick Spiers
A: 

you were almost there.

select * from student where  class='10' AND/OR names in ('kiran', 'manju', 'ram' , 'peter') AND/OR Language='english'
ps
A: 

If you are hard coding the values for the IN clause, previous answers are good. If you are collecting the values dynamically, you will need to use parameters: http://www.mikesdotnetting.com/Article/116/Parameterized-IN-clauses-with-ADO.NET-and-LINQ

MikeB