Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 根据数值差异选择_Mysql_Vb.net_Sql - Fatal编程技术网

Mysql 根据数值差异选择

Mysql 根据数值差异选择,mysql,vb.net,sql,Mysql,Vb.net,Sql,我有一个数据库表,保存订单信息,并在输入时自动保存当前黄金价格世界价格 如果我回头看表,并且保存的黄金价格与当前黄金价格+100存在差异,我想在报告中显示这一点 如何编写MySQL查询来实现这一点?我知道如何做DateDiff,但不知道数值 例如: select * from table where saved_price < current_price - 100 有更好的方法吗?如果差异符号无关紧要,请使用: select * from table where abs(saved_p

我有一个数据库表,保存订单信息,并在输入时自动保存当前黄金价格世界价格

如果我回头看表,并且保存的黄金价格与当前黄金价格+100存在差异,我想在报告中显示这一点

如何编写MySQL查询来实现这一点?我知道如何做DateDiff,但不知道数值

例如:

select * from table where saved_price < current_price - 100
有更好的方法吗?

如果差异符号无关紧要,请使用:

select * from table where abs(saved_price - current_price) > 100
如果这个标志很有趣,你建议的方法是好的。我会这样写,但是用你认为最容易阅读和理解的方式:

select * from table where (current_price - saved_price) >= 100
如果差异符号无关紧要,则使用:

select * from table where abs(saved_price - current_price) > 100
如果这个标志很有趣,你建议的方法是好的。我会这样写,但是用你认为最容易阅读和理解的方式:

select * from table where (current_price - saved_price) >= 100