Which SQL Query below is correct for deleting all records from 'Products' table having product names starting with 'M'?
Which SQL Query below is correct for deleting all records from 'Products' table having product names starting with 'M'?
Solution
The SQL command to delete rows from a table is DELETE FROM table WHERE condition;. To match names starting with 'M', the condition uses LIKE with the wildcard %, which stands for any number of characters. So ProductName LIKE 'M%' selects every name beginning with M, and DELETE FROM Products WHERE ProductName LIKE 'M%'; removes exactly those rows.
Options 2 and 4: REMOVE is not an SQL command.
Option 3: DROP deletes whole objects such as a table or database, not rows, and has no DROP FROM form.
Options 3 and 4: IS works only with NULL (for example IS NULL), not with pattern matching.
Related questions:
2025: 30 May Shift 2
2026: 23 May Shift 1
2026: 11 May Shift 2