티스토리 뷰


mysql> select * from names;
+------+-------+
| id   | name  |
+------+-------+
|    1 | Lucho |
|    2 | Lily  |
|    3 | Kiro  |
+------+-------+
3 rows in set (0.00 sec)

mysql> select * from prof;
+-----------+------------+
| person_id | prof       |
+-----------+------------+
|         1 | Programmer |
|         2 | QA         |
|         3 | Sys admin  |
+-----------+------------+
3 rows in set (0.00 sec)

mysql> update names inner join prof on (id = person_id) set prof = 'Workless' where name = 'Kiro';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from prof;
+-----------+------------+
| person_id | prof       |
+-----------+------------+
|         1 | Programmer |
|         2 | QA         |
|         3 | Workless   |
+-----------+------------+
3 rows in set (0.00 sec)

mysql> delete from names, prof using names inner join prof on (id = person_id) where name = 'Kiro';
Query OK, 2 rows affected (0.00 sec)

mysql> select * from names;
+------+-------+
| id   | name  |
+------+-------+
|    1 | Lucho |
|    2 | Lily  |
+------+-------+
2 rows in set (0.00 sec)

mysql> select * from prof;
+-----------+------------+
| person_id | prof       |
+-----------+------------+
|         1 | Programmer |
|         2 | QA         |
+-----------+------------+
2 rows in set (0.00 sec)

mysql>

'웹개발 > DataBase' 카테고리의 다른 글

pg_dump 뜨기  (0) 2013.11.02
mysql offset 속도!! 대처방법  (0) 2012.03.16
PGSQL 명령어 모음  (0) 2012.02.08
SELECT INTO, INSERT INTO SELECT  (0) 2012.01.18
MYSQL 쿼리 로그 남기기  (0) 2011.12.14
댓글
D-DAY
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함