Skip to content

Instantly share code, notes, and snippets.

@moriya-hm5
Created October 27, 2019 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moriya-hm5/5fca6fffce76527326aa7f2bc503586d to your computer and use it in GitHub Desktop.
Save moriya-hm5/5fca6fffce76527326aa7f2bc503586d to your computer and use it in GitHub Desktop.
mysql> insert into m_emp (empno,empname,departmentid) values (3,'takahashi','101010'); ← empnoを3で指定する
Query OK, 1 row affected (0.29 sec)
mysql> select * from m_emp;
+---------------------+------------+--------------+
| empno | empname | departmentid |
+---------------------+------------+--------------+
| 3 | takahashi | 101010 | ← レコードが追加されている
| 5 | 従業員A | 10101001 |
| 6 | 従業員B | 10101001 |
| 7 | 従業員C | 10101002 |
| 8 | 従業員D | 10101003 |
| 1234567890123456789 | NULL | NULL |
| 1234567890123456790 | takahashi | 101010 |
+---------------------+------------+--------------+
7 rows in set (0.00 sec)
mysql> select last_insert_id();
+---------------------+
| last_insert_id() |
+---------------------+
| 1234567890123456790 | ← 変わっていない
+---------------------+
1 row in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment