Skip to content
Correct queryIntermediate5 questions

Correct the query

NULL handling, aggregates, anti-joins and OR precedence in SQL and Eloquent.

  1. 01This query is meant to list users that have not been soft deleted, but it returns no rows. What is the fix?
    SELECT * FROM users WHERE deleted_at = NULL;
  2. 02Which query lists the customers who have placed more than five orders?
  3. 03Which query returns the users who have no orders at all?
  4. 04This should return active users who are admins or editors, but it also returns inactive editors. Which version is correct?
    User::where('active', true)
        ->where('role', 'admin')
        ->orWhere('role', 'editor')
        ->get();
  5. 05The phone column is NULL for some users. What is the difference between these two counts?
    SELECT COUNT(*), COUNT(phone) FROM users;

Answers are scored on the server. Unanswered questions count as incorrect.

laravel.now is an independent community project. It is not affiliated with, endorsed by, sponsored by, or in any way officially connected to Laravel, Laravel LLC, Taylor Otwell, or the Laravel framework maintainers. Laravel is a trademark of Taylor Otwell. All other trademarks belong to their respective owners.

This site is operated by the makers of Lockhound. Links to Lockhound are promotional.