MySQL Update Trigger with Conditions

Posted by user1760656 on Stack Overflow See other posts from Stack Overflow or by user1760656
Published on 2012-10-19T22:59:05Z Indexed on 2012/10/19 23:00 UTC
Read the original article Hit count: 148

Filed under:
|
|
|

I have a PHP app that inserts 'Pass', 'Fail' or 'NA' into fields TEST1, TEST2, TEST3... through TEST15.

I have a field called OVERALL that needs to be automatically updated with 'FAIL' if any of the TEST1-TEST15 fields contains 'Fail'.

I'm pretty sure I need to use a trigger containing the update statement and either CASE or IF, but I haven't been able to nail down the exact syntax.

Can anyone please help a MySQL noob? I'm using MySQL Server version: 5.1.63-0+squeeze1 (Debian).

© Stack Overflow or respective owner

Related posts about mysql

Related posts about if-statement