Reputation: 13
I want to insert to type field max id from other table but I need to connect it with text information as "Created new user with id = "MAX(my_employee.id). Code that work but insert only id:
INSERT INTO my_logs (user_id, type, date)
SELECT '1', MAX(my_employee.id), '2013-05-28 23:52:07' FROM my_employee
I tried:
INSERT INTO my_logs (user_id, type, date)
SELECT '1',"Created new user with id =" MAX(my_employee.id),
'2013-05-28 23:52:07' FROM my_employee
and similar but nothing seems to work
Upvotes: 0
Views: 76
Reputation: 1269623
Are you trying to do this?
INSERT INTO my_logs (user_id, type, date)
SELECT '1', concat('Created new user with id =', MAX(my_employee.id)),
'2013-05-28 23:52:07'
FROM my_employee;
Upvotes: 1
Reputation: 62831
This should work for you:
insert into my_logs
select 1, concat('Created new user with id = ', MAX(id)), '2013-05-28 23:52:07'
from my_employee
Upvotes: 1