Home  >  Q&A  >  body text

How to check if created_in column is inside trigger?

Column and trigger structures in user tables

CREATE TABLE `users` (
 `created_in` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
trigger event sheet statement time
... insert user IF NEW.created_in = "" THEN

SIGNAL SQLSTATE "45000";

IF END

Before

I'm trying to cancel the insert if the created_in column isn't there but that doesn't work.

How to check whether the created_in column is none?

MySQL version is 5.7

P粉668113768P粉668113768180 days ago322

reply all(1)I'll reply

  • P粉021708275

    P粉0217082752024-04-04 16:19:39

    No trigger is required, session strict mode is enough:

    db<>violinhere

    reply
    0
  • Cancelreply