# Help to understand MySql Query in Script

**URL:** <https://forum.shopware.com/t/help-to-understand-mysql-query-in-script/89715>\
**Category:** Shopware 5\
**Created:** [12. August 2021 um 04:13 UTC](https://forum.shopware.com/t/help-to-understand-mysql-query-in-script/89715 "2021-08-12T04:13:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmiller10](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@kmiller10](https://forum.shopware.com/u/kmiller10)\
**Post date:** [12. August 2021 um 04:13 UTC](https://forum.shopware.com/t/help-to-understand-mysql-query-in-script/89715/1 "2021-08-12T04:13:51Z")

</div>

Hello,

recently I got an error while trying to update a Shopware Shop.

Some other users got the same error too and solved it with removing two lines in one of the update scripts. But before removing them I tried to understand whats going on there to not break anything with it. The affected code is:

```auto
        $sql = <<<'SQL'
        SET @parent = (SELECT id FROM s_core_config_forms WHERE name = 'Checkout' LIMIT 1);

        INSERT IGNORE INTO `s_core_config_elements` (`id`, `form_id`, `name`, `value`, `label`, `description`, `type`, `required`, `position`, `scope`, `options`) VALUES
        (NULL, @parent, 'showVoucherModeForCheckout', 'i:2;', 'Gutscheinfeld im Bestellabschluss anzeigen', NULL, 'select', 0, 0, 0, '%s');

        SET @voucherModeElementId = (SELECT id FROM `s_core_config_elements` WHERE `name` = 'showVoucherModeForCheckout' LIMIT 1);
        INSERT IGNORE INTO `s_core_config_element_translations` (`element_id`, `locale_id`, `label`)
        VALUES (@voucherModeElementId, '2', 'Display voucher field on checkout page');

        SET @commentArticleElementId = (SELECT id FROM `s_core_config_elements` WHERE `name` = 'commentVoucherArticle'); 
        --UPDATE `s_core_config_elements` SET `description` = 'Artikel hinzuf&uuml;gen, Kommentarfunktion', name = 'commentArticle' WHERE id = @commentArticleElementId;
        --UPDATE `s_core_config_element_translations` SET description = 'Add product, comment function' WHERE element_id = @commentArticleElementId;
SQL;

```

> **Summary**
>
> The two lines I commented out with ‚–‘ at the end are the ones I have to remove.
> 
> The Error I got while updating is:
> 
> ```auto
> Could not apply migration (Migrations_Migration1607). Error: SQLSTATE[HY000]: General error: 1093 You can't specify target table 's_core_config_values' for update in FROM clause 
> 
> ```
> 
> I also checked which value „@voucherModeElementId“ and „@commentArticleElementId“ have after the select [filesynced](https://filesynced.org) statement and it turns out that there is no entry with name ‚showVoucherModeForCheckout‘ in table ‚s\_core\_config\_elements‘.
> 
> And the id of the entry with name = ‚commentVoucherArticle‘ in s\_core\_config\_elements is 877. So ‚@commentArticleElementId‘ has the value 877 I think.
> 
> Can anyone explain me what the two lines are doing and maybe even why I got the error?
> 
> This text will be hidden

---

<div class="post-metadata">

**Author:** ![NextMike](https://avatars.discourse-cdn.com/v4/letter/n/838e76/32.png) [@NextMike](https://forum.shopware.com/u/NextMike)\
**Post date:** [12. August 2021 um 07:58 UTC](https://forum.shopware.com/t/help-to-understand-mysql-query-in-script/89715/2 "2021-08-12T07:58:41Z")

</div>

The error is referring to the table s\_core\_config\_values. But your SQL is not. It has to be something else. The commented out lines look very innocent.
