Mariadb is giving warning for this query and table
You expect the subselect (select meta_value from test3 where meta_key='lead_date') to materialize only rows that contain values in meta_value that can be converted to the DATE data type, but this is not happening: the optimizer inlines the subselect and simultaneously applies two predicates: meta_key='lead_date' and date(meta_value)&lt;CURDATE() to all rows in the table, which obviously fails for rows containing 'facebook' in meta_value.