简体   繁体   English

如何编写查询以选择语句在列IN

[英]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 我写了一个查询,其中表名是student,具有列, 类,名称,语言

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 谢谢

Use the "IN" Keyword 使用“ IN”关键字

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

你快到了。

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. 如果您要对IN子句的值进行硬编码,那么前面的答案是好的。 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 如果要动态收集值,则需要使用参数: http : //www.mikesdotnetting.com/Article/116/Parameterized-IN-clauses-with-ADO.NET-and-LINQ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM