gpt4 book ai didi

mysql - 两个值之间的 SQL 标准

转载 作者:太空宇宙 更新时间:2023-11-03 11:53:48 25 4
gpt4 key购买 nike

我想知道,当我们使用“between”时,SQL Standard 或 MySQL 中是否存在差异。更准确地说,在 SQL 标准中,如果我这样做:

A between 1 and 10 

是否等于:

1 <= A and A <= 10
-- or
1 < A ans 1 < 10

在MySQL中结果是否相同

最佳答案

来自 mysql dev doc

expr BETWEEN min AND max

If expr is greater than or equal to min and expr is less than or equal to max, BETWEEN returns 1, otherwise it returns 0. This is equivalent to the expression (min <= expr AND expr <= max) if all the arguments are of the same type. Otherwise type conversion takes place according to the rules described in Section 12.2, “Type Conversion in Expression Evaluation”, but applied to all the three arguments.

它明确指出A between 1 and 10 将等于1 <= A and A <= 10

关于mysql - 两个值之间的 SQL 标准,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34242254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com