0
0
MySQLquery~5 mins

DELETE with WHERE clause in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the DELETE statement do in SQL?
The DELETE statement removes rows from a table based on a condition or all rows if no condition is specified.
Click to reveal answer
beginner
Why is the WHERE clause important in a DELETE statement?
The WHERE clause limits which rows get deleted. Without it, all rows in the table will be removed.
Click to reveal answer
beginner
Write a DELETE statement to remove all users with age less than 18 from a table named 'users'.
DELETE FROM users WHERE age < 18;
Click to reveal answer
intermediate
What happens if you run DELETE FROM employees without a WHERE clause?
All rows in the 'employees' table will be deleted, leaving the table empty.
Click to reveal answer
intermediate
Can you use multiple conditions in the WHERE clause of a DELETE statement? How?
Yes, you can combine conditions using AND, OR. For example: DELETE FROM orders WHERE status = 'cancelled' AND order_date < '2023-01-01';
Click to reveal answer
What does the WHERE clause do in a DELETE statement?
ASpecifies the columns to delete
BSpecifies the table to delete
CSpecifies which rows to delete
DSpecifies the database to delete
What happens if you omit the WHERE clause in a DELETE statement?
AOnly one row is deleted
BAll rows in the table are deleted
CNo rows are deleted
DThe table structure is deleted
Which of the following is a correct DELETE statement to remove users named 'John'?
ADELETE FROM users WHERE name = 'John';
BREMOVE FROM users WHERE name = 'John';
CDELETE users WHERE name = 'John';
DDELETE * FROM users WHERE name = 'John';
How can you delete rows where age is greater than 30 and status is 'inactive'?
ADELETE FROM table WHERE age > 30 OR status = 'inactive';
BDELETE FROM table WHERE age > 30 status = 'inactive';
CDELETE FROM table WHERE age > 30, status = 'inactive';
DDELETE FROM table WHERE age > 30 AND status = 'inactive';
Which SQL keyword is used to delete rows from a table?
ADELETE
BREMOVE
CDROP
DERASE
Explain how to safely delete specific rows from a table using the DELETE statement.
Think about how to target only the rows you want to remove.
You got /5 concepts.
    Describe what happens if you run a DELETE statement without a WHERE clause and why it can be risky.
    Consider the effect on the whole table.
    You got /4 concepts.