sqlbeginner10 minutes
Fix the Bug in SQL Query to Filter Active Users
Identify and fix the bug in the provided SQL query that is supposed to retrieve only active users from the users table.
Challenge prompt
The following SQL query is intended to select all users where the status is 'active'. However, it is returning all users regardless of their status. Find and fix the bug so that only active users are retrieved.
Guidance
- • Check the WHERE clause syntax carefully.
- • Make sure the string comparison is done correctly.
- • Test the query after fixing to ensure only active users are listed.
Hints
- • Remember that string literals in SQL need to be enclosed in single quotes.
- • Look for any misplaced or missing quotation marks around 'active'.
- • Check if the condition is using '=' or '==' incorrectly.
Starter code
SELECT * FROM users WHERE status = active;Expected output
Only rows where the status column equals 'active' should be returned.
Core concepts
SQL WHERE clauseString comparisonBasic SELECT query
Challenge a Friend
Send this duel to someone else and see if they can solve it.