将Sql Query转换为Laravel Query

时间:2016-11-23 17:41:54

标签: php sql laravel-5

我无法将我的sql转换为Laravel查询。

$users = DB::select(DB::raw(
            'SELECT User.*, Registration_Update.created_at as lastRegistrationUpdate
            FROM User
            JOIN Registration_Update
            ON Registration_Update.user_id = User.id
            WHERE Registration_Update.created_at = (
              SELECT MAX(Registration_Update.created_at)
              FROM Registration_Update
              WHERE User.id = Registration_Update.user_id
            )
            AND Registration_Update.deleted_at IS NULL'
    ));

1 个答案:

答案 0 :(得分:0)

已解决代码:

thing