0
0
MySQLquery~10 mins

Comparison operators in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select all rows where age is equal to 30.

MySQL
SELECT * FROM users WHERE age [1] 30;
Drag options to blanks, or click blank then click option'
A>
B!=
C=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '=' will select rows where age is not 30.
Using '>' or '<' will select rows with age greater or less than 30, not equal.
2fill in blank
medium

Complete the code to select all rows where salary is greater than 50000.

MySQL
SELECT * FROM employees WHERE salary [1] 50000;
Drag options to blanks, or click blank then click option'
A>
B<=
C=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '<=' will select salaries less than or equal to 50000.
Using '=' will select only salaries exactly 50000.
3fill in blank
hard

Fix the error in the code to select rows where score is not equal to 100.

MySQL
SELECT * FROM results WHERE score [1] 100;
Drag options to blanks, or click blank then click option'
A<>
B!=
C==
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using == causes syntax errors in SQL.
Using = selects rows equal to 100, not different.
4fill in blank
hard

Fill both blanks to select rows where price is between 10 and 20 (inclusive).

MySQL
SELECT * FROM products WHERE price [1] 10 AND price [2] 20;
Drag options to blanks, or click blank then click option'
A>=
B<
C<=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using > or < excludes the boundary values.
Mixing up the operators will select wrong price ranges.
5fill in blank
hard

Fill all three blanks to select rows where quantity is greater than 5, less than 15, and not equal to 10.

MySQL
SELECT * FROM inventory WHERE quantity [1] 5 AND quantity [2] 15 AND quantity [3] 10;
Drag options to blanks, or click blank then click option'
A>
B<
C!=
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of != will select quantity equal to 10.
Using wrong comparison operators will select incorrect rows.