我可以使用“ as”作为Laravel雄辩或MySQL的变量?
我在应用程序中拥有的是以下两个查询:
SUM(cost_of_sales + commissions) as sales_costs
SUM((cost_of_sales + commissions) * tax) as sales_costs
我想要的是将sales_costs用作从第一个查询到第二个查询的变量。
我想实现的外观如下:
SUM(cost_of_sales + commissions) as sales_costs
SUM(sales_cots * tax)
如何在Laravel雄辩中实现这一目标?
提前致谢。
What I have in my application are the following two queries:
SUM(cost_of_sales + commissions) as sales_costs
SUM((cost_of_sales + commissions) * tax) as sales_costs
What I want is to use sales_costs as a variable from the first query into the second one.
What I want to achieve looks something like the following:
SUM(cost_of_sales + commissions) as sales_costs
SUM(sales_cots * tax)
How can I achieve this in Laravel Eloquent?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的解决方案是使用原始功能。
请参阅 RAW表达式
The simplest solution to this would be to use the raw functionality.
See Raw Expressions