Optimizing the repeated use of the same if condition inside a VIEW? CREATE OR REPLACE VIEW VIEW_NAME AS (
SELECT 
    table0.fieldBlah "FieldBlah",
    --more fields
    IF(table1.foo or table2.foo IN ('State1', 'State2'), 0, table3.uniqueField) "uniqueFieldName")
    IF(table1.foo or table2.foo IN ('State1', 'State2'), 0, table3.uniqueField2) "uniqueFieldName2")
    --more of these if statements with the same condition ,but different field
FROM table1 
--various joins with other tables
);


I was wondering if following principles of DRY (don't repeat yourself) there would be a means of storing the same boolean condition being use in the IF statements for reuse to clean up the code and possibly make the query run better.

I have tried setting a boolean variable

set booleanIfCondition = table1.foo or table2.foo IN ('State1', 'State2');


However I get syntax errors whether I place it before the if statement or try to sneak in somewhere after the select.
Test 

CREATE OR REPLACE VIEW VIEW_NAME AS (
SELECT 
    table0.fieldBlah "FieldBlah",
    --more fields
    IF(@tmp := (table1.foo or table2.foo IN ('State1', 'State2')), 0, table3.uniqueField) "uniqueFieldName",
    IF(@tmp, 0, table3.uniqueField2) "uniqueFieldName2",
    --more of these if statements with the same condition ,but different field
FROM table1 
--various joins with other tables
);