gpt4 book ai didi

mysql - 在 mysql 中创建一个 Where 子句

转载 作者:行者123 更新时间:2023-12-01 00:13:16 24 4
gpt4 key购买 nike

find_by_sql("SELECT s.productcode, s.description, CAST(SUM(l.amount) as UNSIGNED) AS amount FROM softwares s LEFT JOIN licenses l ON s.id=l.software_id GROUP BY s.productcode, s.description WHERE s.supplier= 'softcat'")

我目前有这个,我在 SoftwaresController#export_softcat 中收到错误 ActiveRecord::StatementInvalid

我试图在末尾添加一个 where 子句以仅选择特定供应商的记录。

最佳答案

SELECT s.productcode, s.description, CAST(SUM(l.amount) as UNSIGNED) AS amount
FROM softwares s
LEFT JOIN licenses l ON s.id=l.software_id
WHERE s.supplier = 'softcat'
GROUP BY s.productcode, s.description

这样试试

关于mysql - 在 mysql 中创建一个 Where 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12071765/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com