BETWEEN 查询返回零或一 [英] Query with BETWEEN returns Zero or ONE

查看:30
本文介绍了BETWEEN 查询返回零或一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个查询:

SELECT `fecha` BETWEEN '1390950000' AND '1391126400',
    GROUP_CONCAT(CONCAT_WS('|', `idItem`, `nombreItem`, `cantidad`, `diferencia`) ORDER BY `idItem`) schedule
FROM inventarioStat
GROUP BY fecha ASC;

问题出在 BETWEEN 部分.它返回零还是一?有什么建议吗?

The problem is in the BETWEEN part. It returns zero or one? Any suggestions?

推荐答案

MySQL 将比较操作视为布尔值,其值为 0 或 1.

MySQL treats comparison operations as booleans, which take on a value of 0 or 1.

您在 select 子句中放置了 between.因此,它返回 0(假)或 1(真).其他比较运算符也是如此,例如 =<><= 等.

You have put a between in the select clause. So, it is returning either 0 (for false) or 1 (for true). The same would be true of other comparison operators, such as =, <>, <= and so on.

大概,您希望在 where 子句中使用它:

Presumably, you want it in a where clause:

SELECT fecha,
       GROUP_CONCAT(CONCAT_WS('|', `idItem`, `nombreItem`, `cantidad`, `diferencia`) ORDER BY `idItem`
                   ) as schedule
FROM inventarioStat
WHERE `fecha` BETWEEN '1390950000' AND '1391126400'
GROUP BY fecha ASC;

这篇关于BETWEEN 查询返回零或一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆