开发者

self join to avoid group by

开发者 https://www.devze.com 2023-03-14 20:03 出处:网络
The following query is working as expected and showing me my triggers. SELECT TRIGGER_SCHEMA, EVENT_OBJECT_TABLE,

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消