guypary
guypary

Reputation: 1

How to insert in to a table from another table

I have two tables employee and time_stamp each employee has his hex and emp_id and i want to insert into time_stamp table the time the hex that will come from the time stamping machine and the emp_id from the employee table... this is my query ..

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

and thats what I get as an error:

FUNCTION junicom.emp_id does not exist

Upvotes: 0

Views: 55

Answers (1)

Strawberry
Strawberry

Reputation: 33935

Just guessing...

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

Upvotes: 1

Related Questions