I have 2 tables:
original {ID, FirstName, LastName}
and
dummy {ID(NULL), FirstName, LastName}
I have to insert into t2.ID the original.ID but only if the FirstName and LastName from both tables are the same. Now, i've tried:
1.Error Code: 1054. Unknown column 't2.FirstName' in 'where clause'
INSERT INTO dummy (ID)
SELECT ID
FROM original
WHERE dummy.FirstName = original.FirstName
AND dummy.LastName = original.LastName;
2.Error Code: 1054. Unknown column 'original.FirstName' in 'where clause'
UPDATE dummy
SET ID = original.ID
WHERE dummy.FirstName=original.FirstName
AND dummy.LastName= original.LastName;
3.Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect.
NOTE: I have to find a way without disableing safe mode.
UPDATE dummy
JOIN original
ON original.FirstName = dummy.FirstName
AND original.LastName = dummy.LastName
SET dummy.IDPacient = original.ID
WHERE original.ID <> 0;
Now if someone could help me understand what i did wrong in each of these 3 cases and/or give me a better solution, i would much appreciate the help.