[英]Checking multiple values returned from an sql query
I am trying to run a query on a table which returns two values (call it fstValue and lstValue). 我正在尝试对返回两个值(称为fstValue和lstValue)的表运行查询。 I am trying to get my query to return True in cases when the fstValue >=0 AND lstValue <=100, and false in all other cases. 我试图让我的查询在fstValue> = 0和lstValue <= 100的情况下返回True,在所有其他情况下返回false。
Is there any way to do this in MySQL? 有什么办法可以在MySQL中做到这一点?
select case when fstValue >=0 AND lstValue <= 100
then 'true'
else 'false'
end as result
from your_table
This one: 这个:
set @firstvalue = 98;
set @lastvalue = 100;
select case when (@firstvalue>=0 and @firstvalue<=100)
and @lastvalue>=0 and @lastvalue<=100 then 'True'
else 'False' end as '0 to 100';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.