UPDATE IGNORE : Update « Insert Delete Update « SQL / MySQL






UPDATE IGNORE

     
mysql>
mysql>
mysql> CREATE   TABLE MATCHES
    ->         (MATCHNO        INTEGER      NOT NULL,
    ->          TEAMNO         INTEGER      NOT NULL,
    ->          EmployeeNO       INTEGER      NOT NULL,
    ->          WON            SMALLINT     NOT NULL,
    ->          LOST           SMALLINT     NOT NULL,
    ->          PRIMARY KEY    (MATCHNO)            );
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> INSERT INTO MATCHES VALUES ( 1, 1,   6, 3, 1);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES ( 2, 1,   6, 2, 3);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES ( 3, 1,   6, 3, 0);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES ( 4, 1,  44, 3, 2);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES ( 5, 1,  83, 0, 3);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES ( 6, 1,   2, 1, 3);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES ( 7, 1,  57, 3, 0);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES ( 8, 1,   8, 0, 3);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES ( 9, 2,  27, 3, 2);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES (10, 2, 104, 3, 2);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES (11, 2, 112, 2, 3);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES (12, 2, 112, 1, 3);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES VALUES (13, 2,   8, 0, 3);
Query OK, 1 row affected (0.00 sec)

mysql>
mysql>
mysql> UPDATE   IGNORE MATCHES
    -> SET      MATCHNO = MATCHNO + 1,
    ->          WON = 2,
    ->          LOST = 3
    -> WHERE    MATCHNO = 4;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql>
mysql> drop table matches;
Query OK, 0 rows affected (0.00 sec)

mysql>

   
    
    
    
    
  








Related examples in the same category

1.Do PLUS calculation in where clause
2.Assign value in select clause
3.Modifying Row Data
4.Update with limitation and calculation
5.Update records with calculation based on two tables
6.Update two tables with calculation
7.Using UPDATE Statements to Modify Data in Joined Tables
8.Update with condition
9.UPDATE statement includes a WHERE clause
10.An UPDATE statement can be qualified by the use of the ORDER BY clause and the LIMIT clause.
11.Update statement using table name alias
12.Update value by calculation
13.Update statement with variable (ERROR 1093 (HY000): You can't specify target table 'PENALTIES' for update in FROM clause)
14.Update and order
15.Update with limit clause
16.Update statement with case statement
17.Update statement with subquery (ERROR 1093 (HY000): You can't specify target table 'PENALTIES' for update in FROM clause)
18.Updates all rows with an InStock value of less than 30
19.Adding Subqueries to Your UPDATE Statements
20.Updating a joined table
21.When you update values in a joined table, you can update more than one value at a time
22.Joining Tables in an UPDATE Statement
23.A different join is defined in the UPDATE clause.
24.SET clause uses the Quantity column to specify the new value for that column