Sobes.tech
Senior

-- Kirjutage päring, mis parandab andmeid: -- asendage parent_id väärtus NULL-iga ainult kategooriates, -- mis viitavad iseendale -- OOTAV TABELI OLEK PÄRINGU PÄRAST -- +----+----------+-----------+ -- | id | nimi | parent_id | -- +----+----------+-----------+ -- | 1 | pharma | NULL // Asendatud NULL-iga -- | 2 | tooted | 4 -- | 3 | mängud | NULL // Asendatud NULL-iga -- | 4 | muusika | 2 -- +----+----------+-----------+

sobes.tech AI

Vastus AI-lt

sql UPDATE categories SET parent_id = NULL WHERE parent_id = id;

Этот запрос обновит таблицу `categories`, установив `parent_id` в NULL для тех записей, у которых `parent_id` равен собственному `id`, то есть категории ссылаются сами на себя.