查看 Mysql 错误但在正常查询中工作

标签 mysql

当我尝试为其创建 View 时出现错误:“ View 的 SELECT 在 FROM 子句中包含一个子查询”,但它在普通查询中工作正常。我认为它与我的 WHERE 子句有关,但我不明白为什么或如何修复它。这是我想要的查询:

select concat(`company`, ' | ', `material`, ' | ', `newcost`) as datarow from( Select `b`.`company` AS `company`, `bp`.`material` AS `material`, if(((`bp`.`cost` * 1.2) < `ls`.`maximumbid`), (`bp`.`cost` * 1.2),`bp`.`cost`) AS `newcost` from (((`windows_brands_products` `bp` left join `windows_brands` `b` on((`bp`.`brand_id` = `b`.`id`))) join `Windows_last_submissions` `ls`) join `windows_materials` `wm`) where ((`bp`.`width` = round(`ls`.`width`,0)) and (`bp`.`height` = round(`ls`.`height`,0)) and (`bp`.`material` = `wm`.`name`) and (`bp`.`type` = `ls`.`type`) and if((`ls`.`minimumbid` <> '0.00'),(`bp`.`cost` between `ls`.`minimumbid` and `ls`.`maximumbid`),(`bp`.`cost` <= `ls`.`maximumbid`))) ) x

为什么会显示此错误以及如何更改它以便我可以将其用作 View (最终我将生成的每个行用作下拉菜单的动态数据)。

最佳答案

Ya 在某种程度上 McAdam331 很可能会有所帮助,但一位 friend 帮助我解决了这个问题。我只是保留了我之前对上述查询的看法,没有使用 concat 内容(从而摆脱了别名)并制作了另一个查看并查询:

select concat(`company`, ' | ', `material`, ' | ', `newcost`) as options
from Windows_last_options

因此引用了“非串联” View 并起作用了!

关于查看 Mysql 错误但在正常查询中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30851083/

相关文章:

Mysql检查。一天的记录与不同日期的记录 'Same-Store Sales'

mysql - 通过选择给定集合的随机元素来更新列 - MySQL

mysql - 插入(使用 select 语句)并根据 select 语句附加 ON DUPLICATE KEY UPDATE

mysql - 最快的数据库引擎来存储巨大的字符串列表

php - 2 或 3 类别搜索复选框 php

php - 使用 LIKE 查询不会与返回的 ajax 数据匹配

php - 在 PHP 中构建嵌套数组

mysql - 将 Ruby/Rails/MRI 应用程序移植到 JRuby

mysql - 将表 1 的单位列更新为表 2

php - 在 Doctrine 1.2 中使用 Mysql 数据类型集