how to get data from one mysql table and insert into another:?

1

I'm trying to make pincode validator (serial), but I do not know how to do it.

I have two tables: "validation" and "expiration".

In the "validation" table, it has the following fields:

id(int), data(varchar), pincode(varchar), status(int)

In the "expiration" table, you have the following fields:

id(int), data(varchar)

I wanted to get the data from the validation table (date) and update it on the expiration table but only update if the serial is correct when typing! and if the status is 0!

exemplo: 
0 = ainda não ativou!
1 = ja foi ativado !

Can anyone help me?

    
asked by anonymous 20.11.2016 / 00:10

1 answer

3

Assuming id is autoincrement :

INSERT INTO vencimento(data)
SELECT v.data
  FROM validacao v
 WHERE v.pincode = 'xxxxxxx'
   and v.status = 0;
    
20.11.2016 / 00:27