DELETE Statement in SQL
Level 4100 keystrokes
DELETE removes the rows that match WHERE; here, inactive sessions idle for more than 30 days.
SQL code
-- Delete rows from the sessions table1DELETE FROM2 sessions-- Only rows matching both conditions are deleted; without WHERE, all rows would go3WHERE -- DATE_SUB(NOW(), INTERVAL 30 DAY) is the moment 30 days ago; older activity matches4 last_activity < DATE_SUB(NOW(), INTERVAL 30 DAY) -- The session must also be marked 'inactive'5 AND status = 'inactive';Output
Query OK, 42 rows affected
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this SQL code and how often they appear.
_× 2'× 2(× 2)× 2,× 1;× 1<× 1=× 1