问题描述
如果一个表有这些列::
列ID ::列名:::列desc :::列a ::列b
如果查询是从表中选择*,其中columnid像'0';
其返回数据与columnid 0 only
我们可以这样做:: select * from table其中columnid如'0','1','2'; ?
if a table have these columns ::
Column ID:: Column Name ::: Column desc ::: column a :: Column b
and if the query is select * from table where columnid like '0';
its return data related to columnid 0 only
and can we do this :: select * from table where columnid like '0','1','2'; ?
推荐答案
ColumnID IN ('0','1','2')
select * from table where columnid = '0';
你真的不能这样做:
You can't really do:
select * from table where columnid like '0','1','2';
如果您要检索columnid值为0 1的记录或2,然后这将工作:
If you are trying to retrieve records that have a columnid value of 0 1 or 2, then this would work:
select * from table where columnid IN ('0','1','2');
...如果将columnid定义为整数数据类型,那么你最好用:
... and if columnid is defined as an integer data type, then you would be better with:
select * from table where columnid IN (0,1,2);
希望有所帮助。
Hope it helps.
这篇关于Sql查询可以添加更多约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!