开发者

how to write Query for select statment where column IN

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 val开发者_JAVA技巧ues?

Looking frwd for solution

thank you


Use the "IN" Keyword

SELECT * FROM students 
WHERE class='10'
AND Names IN ('kiran', 'manju', 'ram' , 'peter')
AND Language = 'english'


you were almost there.

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


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


SELECT * FROM student 
WHERE class = 10 
AND language = 'english' 
AND (names = 'kiran' OR names = 'manju' OR names = 'ram' OR names = 'peter')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜