S
S
sudo rm -rf /2018-07-10 17:03:04
MySQL
sudo rm -rf /, 2018-07-10 17:03:04

Why doesn't the trigger fire as intended?

There is a table notify_text (guild_id, role_id, member_id, text). I want to implement an automatic check that role_id and member_id will not be added to the database at the same time.
I tried to implement a trigger, but it only skips the option when role_id = null and member_id = null. What needs to be corrected? What am I doing wrong?

DELIMITER //
CREATE TRIGGER notify_target_check BEFORE INSERT ON notify_text
    FOR EACH ROW
    BEGIN
        IF NEW.role_id IS NOT NULL AND NEW. member_id IS NOT NULL THEN 
            INSERT INTO 'role_id и member_id не могут быть заполнены одновременно' VALUES(5);
        END IF;
    END//
DELIMITER ;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zxscv, 2018-07-11
@zxscv

check next points "NEW. member_id " remove space
try to add brackets (NEW.role_id IS NOT NULL AND NEW.member_id IS NOT NULL)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question