A
A
Aljo2021-07-19 16:24:16
SQL
Aljo, 2021-07-19 16:24:16

How to insert SELECT in UPDATE?

Hello!
Tried to query the database. to change the template for some pages on the site.

UPDATE `modx_site_content` set `template`=5
WHERE `parent` in (SELECT id FROM `modx_site_content` WHERE `parent`=5 AND `template`=6) AND `class_key`="msProduct"

But the query throws an error: You ca
n't specify target table 'modx_site_content' for update in FROM clause So the question is, how to remake the request?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aljo, 2021-07-19
@aljo222

The issue is resolved, it turned out that these pages have a uri that starts with catalog/ , so

UPDATE `modx_site_content`
SET `template`=5
WHERE `uri` LIKE 'catalog/%' AND `class_key`="msProduct"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question