繁体   English   中英

如何从另一个表插入表

[英]How to insert in to a table from another table

我有两个表employee和time_stamp,每个雇员都有他的hex和emp_id,我想将来自时间戳机器的十六进制和employee表的emp_id的时间插入到time_stamp表中。这是我的查询..

INSERT INTO time_stamp (hex,time,emp_id)
              SELECT emp_id  ({$hex}, NOW() )
              FROM employee
              WHERE hex = {$hex}

那就是我得到的一个错误:

FUNCTION junicom.emp_id does not exist

只是猜测...

INSERT INTO time_stamp (hex,time,emp_id)
SELECT hex, NOW(), emp_id
FROM employee
WHERE hex = '$hex'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM