Unknown column 'REV' in 'where clause'