Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.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/5/sql/80.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_Sql_Select_Calculated Field - Fatal编程技术网

Mysql 如何根据计算值字段选择行

Mysql 如何根据计算值字段选择行,mysql,sql,select,calculated-field,Mysql,Sql,Select,Calculated Field,如何基于同一表中的计算值字段选择行 表A ----------------------- |id | col2 | col3 | --------------------- | 1 | 23 | 33 | | 2 | 33 | 24 | | 3 | 11 | 4 | 我试过了 SELECT id, (col2 + col3) as NV WHERE NV > 50 不幸的是,它无法工作。。。感谢您的帮助…您不能在定义别名的w

如何基于同一表中的计算值字段选择行

表A

-----------------------
|id   | col2  | col3  |
---------------------
| 1   |  23   |  33   |
| 2   |  33   |  24   | 
| 3   |  11   |  4    |
我试过了

SELECT id, (col2 + col3) as NV WHERE NV > 50 

不幸的是,它无法工作。。。感谢您的帮助…

您不能在定义别名的
where
子句中使用与
select
相同级别的别名

MySQL有一个扩展,允许您为此使用
having
子句:

SELECT id, (col2 + col3) as NV 
FROM . . . 
HAVING NV > 50 ;

您不能在定义别名的
where
子句中使用与
select
相同级别的别名

MySQL有一个扩展,允许您为此使用
having
子句:

SELECT id, (col2 + col3) as NV 
FROM . . . 
HAVING NV > 50 ;