查看Mysql错误但在普通查询中工作

时间:2015-06-15 17:13:59

标签: mysql

我收到一个错误:“当我尝试为它创建一个视图时,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

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

1 个答案:

答案 0 :(得分:0)

Ya在某种程度上最有可能帮助了McAdam331,但是一位朋友帮助我解决了这个问题。我只是保留了我之前查询的上述查询而没有连续的东西(因此摆脱了别名)并制作了另一个查看和查询:

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

所以引用了“非连接”视图并且工作了!

相关问题