mysql子查询重命名_子查询where子句中的MYSQL别名

  • Post author:
  • Post category:mysql

我在子查询中遇到别名问题.

我有一个问题:

SELECT

`id` as `t`,

`title`,

`once`,

(select count(`id`) from `orders_files` where `order_id`=’116815′ and `type`=`t` and (`version`=’41924′) ) as `count`,

(select count(`id`) from `orders_files` where `order_id`=’116815′ and `type`=`t` ) as `count_in_order`

FROM

`orders_filetypes`

WHERE

`required`=1

ORDER BY `sort`, `title`

它运行并运行在旧版本的mysql(5.6.22)上,并且不适用于新版本的mysql(5.7.9). mysql错误是“#1054 – ‘where子句’中的未知列’t’”.

配置文件是相同的,问题是我不明白.

我们更新了mysql服务器,许多查询停止工作.

请告诉我,这个功能在较新的mysql中已被弃用,或者可以设置为/etc/my.cnf?

如果可以使用这些请求,则无法找到并修复数十万行代码,因此最好在新服务器中包含这种可能性.

谢谢!


版权声明:本文为weixin_42509518原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。