$string = $a . ' where '; if( $b ) { $string .= $c ? "$b and $c" : $b } elsif( $c ) { $string .= $c } else { # Assert }