E
E
Eldar Imamverdiyev2021-09-28 10:56:34
MySQL
Eldar Imamverdiyev, 2021-09-28 10:56:34

How to put two conditions in one trigger?

BEGIN
    IF ((SELECT SUM(field_310) FROM app_entity_8 WHERE field_581=(SELECT `id` FROM `app_entity_9`))=(SELECT `field_329` FROM `app_entity_9`)) THEN
        UPDATE `app_entity_9` SET `field_586`=53 WHERE `app_entity_9`.`id`=new.field_581;
    END IF;
    IF ((SELECT SUM(field_310) FROM app_entity_8 WHERE field_581=(SELECT `id` FROM `app_entity_9`))<(SELECT `field_329` FROM `app_entity_9`)) THEN
        UPDATE `app_entity_9` SET `field_586`=54 WHERE `app_entity_9`.`id`=new.field_581;
    END IF;
END

This trigger does not work (1242 - Subquery returns more than 1 row), but if you remove the second condition, it works. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman MySQL, 2021-09-28
Tag

the text of the error says what you are doing wrong

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question