I get empty result in eloquent query builder, whereas copying the sql (from ->toSql( ) function) and run it in phpadmin works perfectly. This is my query:
$reportData=DB::table('my_table')
->select('my_table.*')
->whereRaw("STR_TO_DATE(my_table.date, '%m.%Y') >= STR_TO_DATE('01.2017', '%m.%Y')")
The sql equivalent returned by toSql is:
select *
from my_table
where STR_TO_DATE(my_table.date, '%m.%Y') >= STR_TO_DATE('01.2017', '%m.%Y')
Note: I used another mysql function like UPPER, DATE_FORMAT in whereRaw, and that has no issue; but with STR_TO_DATE it has.
I checked in official site, STR_TO_DATE should work with MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23.
Please help :)
--Update-- I rechecked mysql_log and here I had: - the first log (id=1) is created when running query through laravel - the second log (id=2) is from phpmyadmin