0
0
MySQLquery~10 mins

Why MySQL is widely used - Test Your Understanding

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

Complete the code to select all records from the users table.

MySQL
SELECT * FROM [1];
Drag options to blanks, or click blank then click option'
Aorders
Buser
Cusers
Dcustomers
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular form 'user' instead of 'users'.
Selecting from unrelated tables like 'orders'.
2fill in blank
medium

Complete the code to find users with age greater than 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 '<' which finds ages less than 30.
Using '=' which finds ages exactly 30.
3fill in blank
hard

Fix the error in the query to count users by city.

MySQL
SELECT city, COUNT(*) AS user_count FROM users GROUP BY [1];
Drag options to blanks, or click blank then click option'
Aage
Bname
Cuser_count
Dcity
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by 'age' or 'name' instead of 'city'.
Grouping by the alias 'user_count' which is invalid.
4fill in blank
hard

Fill both blanks to find users whose name starts with 'A' and order by age descending.

MySQL
SELECT * FROM users WHERE name [1] 'A%' ORDER BY age [2];
Drag options to blanks, or click blank then click option'
ALIKE
BASC
CDESC
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of LIKE for pattern matching.
Ordering age ascending instead of descending.
5fill in blank
hard

Fill all three blanks to create a new table named 'employees' with columns 'id' (integer primary key), 'name' (text), and 'salary' (decimal).

MySQL
CREATE TABLE [1] (id [2] PRIMARY KEY, name [3], salary DECIMAL(10,2));
Drag options to blanks, or click blank then click option'
Aemployees
BINTEGER
CTEXT
DVARCHAR(100)
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong table name.
Using TEXT instead of VARCHAR for name.
Not specifying PRIMARY KEY for id.