mysql> update student set grade = 1 where age = 22;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
ysql> update student set grade = 3 where age = 24;
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> update student set grade = 2 where age = 23;
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> update student set grade = 4 where age = 25;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from student;
+------+--------+------+---------+----------+-------+-------+
| num | name | age | address | major | score | grade |
+------+--------+------+---------+----------+-------+-------+
| 1111 | 홍길동 | 24 | seoul | computer | 89 | 3 |
| 2222 | 강길순 | 25 | seoul | English | 87 | 4 |
| 3333 | 이순신 | 23 | Inchen | English | 57 | 2 |
| 5555 | 유관순 | 22 | suwon | Computer | 97 | 1 |
| 6666 | 다래냥 | 2 | Inchen | computer | 100 | NULL |
| 7777 | 다래옹 | 24 | Inchen | English | 20 | 3 |
| 8888 | 다래잉 | 27 | Inchen | computer | 80 | NULL |
| 9999 | 다래뇽 | 23 | seoul | computer | 70 | 2 |
+------+--------+------+---------+----------+-------+-------+
8 rows in set (0.00 sec)
'DB > 명령프롬프트 - mysql' 카테고리의 다른 글
[MySQL] 정렬 (order by asc / desc) (0) | 2023.03.27 |
---|---|
[MySQL] student table - 모든 학생의 age를 +1 업데이트 (0) | 2023.03.27 |
[MySQL] 테이블 정보를 타 테이블로 이동 (0) | 2023.03.27 |
[MySQL] student table - 테이블의 값을 다른 테이블로 옮기기 (4학년 친구들을 졸업) (0) | 2023.03.27 |
[MySQL] product table - 테이블 생성 예제 (0) | 2023.03.27 |