Factorise the MySQL condition constructions