0

我想从其他表中插入输入字段 max id,但我需要将其与文本信息连接为“使用 id =”MAX(my_employee.id) 创建的新用户。有效但仅插入 id 的代码:

INSERT INTO my_logs (user_id, type, date) 
        SELECT '1', MAX(my_employee.id), '2013-05-28 23:52:07' FROM my_employee

我试过了:

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

和类似的,但似乎没有任何效果

4

2 回答 2

1

这应该适合你:

insert into my_logs  
select 1, concat('Created new user with id = ', MAX(id)), '2013-05-28 23:52:07' 
from my_employee
于 2013-05-28T23:27:56.973 回答
1

你想这样做吗?

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;
于 2013-05-28T23:28:10.427 回答