0
0
MySQLquery~10 mins

Relational database concepts 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 columns from the table named 'employees'.

MySQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
Acolumns
BALL
C*
Deverything
Attempts:
3 left
💡 Hint
Common Mistakes
Writing 'ALL' instead of '*'
Using words like 'columns' or 'everything' which are not valid SQL keywords
2fill in blank
medium

Complete the code to filter employees whose age is greater than 30.

MySQL
SELECT * FROM employees 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 means less than
Using '=' which means equal to
3fill in blank
hard

Fix the error in the code to count the number of employees.

MySQL
SELECT COUNT([1]) FROM employees;
Drag options to blanks, or click blank then click option'
Aage
B*
Cname
Dsalary
Attempts:
3 left
💡 Hint
Common Mistakes
Counting a specific column which may ignore NULL values
Using a column name instead of '*'
4fill in blank
hard

Fill both blanks to select distinct departments and order them alphabetically.

MySQL
SELECT [1] department FROM employees ORDER BY department [2];
Drag options to blanks, or click blank then click option'
ADISTINCT
BDESC
CASC
DALL
Attempts:
3 left
💡 Hint
Common Mistakes
Using ALL instead of DISTINCT
Ordering with DESC which sorts in reverse alphabetical order
5fill in blank
hard

Fill all three blanks to create a new table named 'departments' with columns 'id' as integer primary key and 'name' as text.

MySQL
CREATE TABLE [1] ([2] INT PRIMARY KEY, [3] TEXT);
Drag options to blanks, or click blank then click option'
Adepartments
Bid
Cname
Demployees
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong table name like 'employees'
Swapping column names or missing PRIMARY KEY