Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.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 Sql查询列在casted as字段的何处未知_Mysql_Sql_Casting - Fatal编程技术网

Mysql Sql查询列在casted as字段的何处未知

Mysql Sql查询列在casted as字段的何处未知,mysql,sql,casting,Mysql,Sql,Casting,此查询不起作用 SELECT CAST(o.total as SIGNED INTEGER) as yakk FROM `order` o WHERE yakk = '51' ORDER BY `o`.`order_id` DESC limit 0, 50 它说yakk列是uknown,而如果我删除where子句,它会工作,并显示列在where条件下不能使用别名,必须重复代码 (如果强制转换为整数,则使用int进行比较) 为select创建的别名不适用于where,因为wh

此查询不起作用

 SELECT CAST(o.total as SIGNED INTEGER) as yakk 
 FROM `order` o   
 WHERE yakk  = '51' ORDER BY `o`.`order_id` DESC  limit 0, 50 

它说yakk列是uknown,而如果我删除where子句,它会工作,并显示列

在where条件下不能使用别名,必须重复代码 (如果强制转换为整数,则使用int进行比较)


为select创建的别名不适用于where,因为where条件在select子句之前被求值

您不能在where条件中使用别名,必须重复代码 (如果强制转换为整数,则使用int进行比较)


为select创建的别名不适用于where,因为where条件是在select子句之前求值的

,而不是where use having plus one或where use having plus one
SELECT CAST(o.total as SIGNED INTEGER) as yakk 
FROM `order` o   
WHERE CAST(o.total as SIGNED INTEGER)  = 51 ORDER BY `o`.`order_id` DESC  limit 0, 50