MySQL - 在自定义列上创建搜索

时间:2015-09-17 09:08:46

标签: mysql sql laravel laravel-5 query-builder

我想运行这样的MySQL查询:

 SELECT * FROM `project` WHERE (project.sold_tons + project.recycled_tons + project.recycled_tons + project.donation_tons)*100/project.total_excess_furniture)>90

当我运行它时,我收到如下错误:

#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ')>90 ORDER BY `is_archived` DESC 
LIMIT 0, 25' at line 1 

我可以这样做吗? 要么, 是否有任何替代解决方案来创建这样的搜索?

如果没有,那么Laravel或MySQL中的解决方案是什么?

感谢您的帮助..

2 个答案:

答案 0 :(得分:3)

你错过'('之后

试试这个

SELECT * FROM `project` 
WHERE ((project.sold_tons + project.recycled_tons + project.recycled_tons + project.donation_tons) *100/project.total_excess_furniture) > 90

答案 1 :(得分:0)

project.total_excess_furniture)< - 此范围是额外的