I am trying to copy data from table to another mysql table from two different databases
First I get all data from first table and stored them into php variable
then I loop on that var to insert data to the other table
using this query
INSERT INTO `users` (`nUserId`, `vLoginName`, `vFirstName`, `vLastName`, `vEmail`)
VALUES ('$entity_id','$name','$firstname','$lastname','$email')
WHERE NOT EXISTS (SELECT `nUserId`,`vEmail`
FROM `users`
WHERE `nUserId`='$entity_id'
AND `vEmail` = '$email')
but it's not working
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE NOT EXISTS (SELECT `nUserId`,`vEmail` FROM users '
What the correct syntax to make this work ?