Updating Data Through a View in MySQL
Yes, you can update data through a view in MySQL, but only if the view is updatable. MySQL allows updates, inserts, and deletes through certain types of views, depending on their structure and rules.
The view is based on a single table.
The SELECT does not include aggregate functions (SUM, COUNT, AVG).
The SELECT does not use DISTINCT, GROUP BY, HAVING, UNION, or LIMIT.
The view includes all NOT NULL columns from the base table (unless columns have default values).
The view does not use subqueries in the SELECT list.
The view contains JOINs.
The view uses aggregate functions or GROUP BY.
The view uses UNION or DISTINCT.
The view is based on multiple tables.
The view contains derived columns (e.g., price * quantity AS total).
The above UPDATE works because the view references a single table and contains no disqualifying features.
WITH CHECK OPTION ensures updates follow the view's WHERE clause.
Prevents updates that would make the row disappear from the view.