逗号在sql中搜索? [英] comma search in sql ?
本文介绍了逗号在sql中搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个sql表城市,其中列是
id city
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9我
现在正在搜索城市,我的参数是
@city = 1,3,4
如何搜索
i have a sql table city where the columns is
id city
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 I
now m searching cities and my parameters is the format of
@city = 1,3,4
how to search it
推荐答案
您可以在SQL中使用IN运算符,IN运算符允许您在WHERE子句中指定多个值。
检查在SQL IN子句中使用逗号分隔值参数字符串代码项目文章。
You can use IN Operator in SQL and the IN operator allows you to specify multiple values in a WHERE clause.
Check Using comma separated value parameter strings in SQL IN clauses Code Project article.
使用IN运算符: -
IN运算符允许您在WHERE子句中指定多个值。
例如: -
1]
Use IN Operator:-
The IN operator allows you to specify multiple values in a WHERE clause.
eg:-
1]
SELECT * FROM TblName WHERE City IN ('A','C','D');
或
2]
Or
2]
SELECT * FROM TblName WHERE ID IN ('1','3','4');
这篇关于逗号在sql中搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文