Answer the question
In order to leave comments, you need to log in
SQL how to combine INSERT INTO and SELECT?
I have this SQL query.
SELECT url_img, object_id FROM images
INNER JOIN products ON images.object_id = products.id
WHERE images.object = "product"
INSERT INTO products (image_url)
SELECT url_img, object_id FROM images
INNER JOIN products ON images.object_id = products.id
WHERE images.object = "product"
UPDATE products
SET products.image_url = image.url_img
SELECT url_img, object_id FROM images
INNER JOIN products ON images.object_id = products.id
WHERE images.object = "product"
Column count doesn't match value count at row 1
Answer the question
In order to leave comments, you need to log in
UPDATE `products`
LEFT JOIN `images` ON `images`.`object_id` = `products`.`id`
SET `products`.`images` = `products`.`url`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question