It doesn’t take much to realize that the code you wrote doesn’t make sense to what you want to do.
UPDATE picture pc
INNER JOIN cars AS c
ON c.image = pc.ImName
SET pc.ImName = c.image;
Used the UPDATE
being that you want to insert new records; made a JOIN
in unrelated tables (or at least you did not comment that there is a foreign key relating them and, if there is one, it was ignored in the code); you made the condition c.image = pc.ImName
the image does not exist in picture
, then the condition will never be satisfied.
I would like to copy all photos from table "Cars" column "image" to table "picture" column "Inname"
How do you want select data from a table and insert in another, you will have to use the SELECT
and the INSERT
.
INSERT INTO picture (InName)
SELECT image FROM cars
This will select all records from cars
, only the column image
and will save on the table picture
. If you don’t need all the records, just add a clause WHERE
in his SELECT
.
How the relationship between the tables is done
cars
andpictures
?– Augusto Vasques
Just make a
INSERT ... SELECT ...
. If the tables are not related, there is no reason to do Join, let alone do an update to insert records.– Woss