我有一个SQL查询要转换为Rails ORM(ActiveRecord)
SELECT * FROM txactions
INNER JOIN accounts
WHERE accounts.item_accountId = 15845388
AND accounts.id = txactions.account_id
答案 0 :(得分:0)
你可以试试这个
Txaction.joins("INNER JOIN accounts ON accounts.id = txactions.account_id").where("accounts.item_accountId = ?", 15845388)
或强>
Txaction.joins(:accounts).where("accounts.item_accountId = ?", 15845388)