Updates all rows with an InStock value of less than 30
mysql>
mysql>
mysql> CREATE TABLE Books
-> (
-> BookID SMALLINT NOT NULL PRIMARY KEY,
-> BookName VARCHAR(40) NOT NULL,
-> InStock SMALLINT NOT NULL
-> )
-> ENGINE=INNODB;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
mysql> INSERT INTO Books
-> VALUES (101, 'C: Writing on Writing', 12),
-> (102, 'Oracle', 17),
-> (103, 'Opera', 23),
-> (104, 'Notebook', 32),
-> (105, 'Pascal', 6),
-> (106, 'One Hundred Years of Solitude', 28);
Query OK, 6 rows affected (0.00 sec)
Records: 6 Duplicates: 0 Warnings: 0
mysql>
mysql> UPDATE LOW_PRIORITY Books
-> SET InStock=InStock+10
-> WHERE InStock<30;
Query OK, 5 rows affected (0.00 sec)
Rows matched: 5 Changed: 5 Warnings: 0
mysql>
mysql> drop table Books;
Query OK, 0 rows affected (0.00 sec)
Related examples in the same category