The following query is working as expected and showing me my triggers.
SELECT TRIGGER_SCHEMA, EVENT_OBJECT_TABLE,
IF(EVENT_MANIPULATION = 'UPDATE' AND ACTION_TIMING='BEFORE', TRIGGER_NAME, '') AS BEFORE_UPDATE,
IF(EVENT_MANIPULATION = 'UPDATE' AND ACTION_TIMING = 'AFTER', TRIGGER_NAM开发者_高级运维E, '') AS AFTER_UPDATE,
IF(EVENT_MANIPULATION = 'INSERT' AND ACTION_TIMING='BEFORE', TRIGGER_NAME, '') AS BEFORE_INSERT,
IF(EVENT_MANIPULATION = 'INSERT' AND ACTION_TIMING = 'AFTER', TRIGGER_NAME, '') AS AFTER_INSERT,
IF(EVENT_MANIPULATION = 'DELETE' AND ACTION_TIMING='BEFORE', TRIGGER_NAME, '') AS BEFORE_DELETE,
IF(EVENT_MANIPULATION = 'DELETE' AND ACTION_TIMING = 'AFTER', TRIGGER_NAME, '') AS AFTER_DELETE
from information_schema.triggers ;
The problem is that if I have 3 AFTER triggers, it shows on 3 separate rows. How do I show all the three on the same line? I tried group by TRIGGER_SCHEMA, EVENT_OBJECT_TABLE - but it showed blank values where the trigger name was expected.
try doing
COALESCE( IF( .... ) ) as FinalColumn
There may be multiple insert/update/delete triggers (or result of cascading) affecting your result.
精彩评论