Update with condition : Update : Insert Delete Update SQL / MySQL


SQL / MySQL » Insert Delete Update » Update »

 

Update with condition



/*

mysql> select * from Bird;
+----------+-------+---------+------+------------+-------+
| name     | owner | species | sex  | birth      | death |
+----------+-------+---------+------+------------+-------+
| BlueBird | Joe   | Car     | f    | 1999-03-30 | NULL  |
+----------+-------+---------+------+------------+-------+
1 row in set (0.00 sec)

mysql> UPDATE Bird SET birth = '1989-08-31' WHERE name = 'BlueBird';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from Bird;
+----------+-------+---------+------+------------+-------+
| name     | owner | species | sex  | birth      | death |
+----------+-------+---------+------+------------+-------+
| BlueBird | Joe   | Car     | f    | 1989-08-31 | NULL  |
+----------+-------+---------+------+------------+-------+
1 row in set (0.03 sec)


*/
Drop table Bird;

CREATE TABLE Bird (
    name VARCHAR(20)
    owner VARCHAR(20),
    species VARCHAR(20)
    sex CHAR(1)
    birth DATE, 
    death DATE
);
  
INSERT INTO  Bird VALUES ('BlueBird','Joe','Car','f','1999-03-30',NULL);
  
select from Bird;

UPDATE Bird SET birth = '1989-08-31' WHERE name = 'BlueBird';


select from Bird;

           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

SQL / MySQL

 Navioo Insert Delete Update
» Update