Quantcast
Viewing all articles
Browse latest Browse all 207

Update rows based on a recursive CTE query result

This query shows all lines recursively based on a uuid / parentUUID relationship:

WITH RECURSIVE files_paths (id, parent) AS(  SELECT uuid, parentuuid    FROM core_data    WHERE uuid = '2c828bbb-71c4-4a00-8d54-d1a4575ec3ef'  UNION ALL  SELECT e.uuid, e.parentuuid    FROM files_paths AS ep JOIN core_data AS e      ON ep.id = e.parentuuid)SELECT id FROM files_paths

However if I need to update lines with provided id (as follows) the query fails:

UPDATE `core_data` SET `attrib` = 'test' WHERE `uuid` IN (SELECT id FROM files_paths)

(Error is "You have an error near...")

Any suggestion is appreciated.


Viewing all articles
Browse latest Browse all 207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>