【问题标题】:How can I implement this in active record?如何在活动记录中实现这一点?
【发布时间】:2011-09-01 12:32:23
【问题描述】:

我想将此问题转移到活动记录中:

我要转移的SQL语句:

SELECT user.name, user.subject
FROM user
INNER JOIN (
    SELECT name, COUNT(1) AS occurrences
    FROM user
    GROUP BY name
  ) AS user_occurrences
  ON user.name = user_occurrences.name
ORDER BY user_occurrences.occurrences DESC, user.name ASC, user.subject ASC
LIMIT 4

How to write this SQL statement?

我可以加入表,但是如何在活动记录中创建一个新表?谢谢你。

【问题讨论】:

    标签: php codeigniter activerecord


    【解决方案1】:

    Active Record 类的功能非常有限。除了在 join 方法中编写子查询之外,您可以做的事情并不多。

    【讨论】:

    • @@" 为什么活动记录如此有限。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多