I have two tables one is called Players
and the other is importdata
. The importdata
table consists of two fields the player id (PID) and the photo (Photo).
In the Players
table I created a column for the Photo field to be imported into. What I would like to do is take the Photo field from the importdata
table and insert it into the photo_high
field in the Players
table where the PID fields match.
I thought something like this would work, but it says that there is an unknown column.
INSERT INTO (`photo_high`)
SELECT PID, Photo
FROM importdata
WHERE Players.PID = importdata.PID
Can this be achieved with an SQL statement or do I have to write some kind of script? Any guidance would be great.
PID
photo_high (empty)
PID
Photo (full of content)
I think you want update
rather than insert
:
update Players p join
ImportData id
on p.Pid = id.pid
set photo_high = id.photo;
insert
creates new rows in a table. update
changes values in existing fields.