When you are executing the code, are you using an SQLite/memory database by chance? Sometimes you'll run across things like this that SQLite just doesn't support.
Dec 7, 2018
2
Level 12
Query failure in laravel, but executes perfectly in the db cli?
What am I missing here? This has to be something so silly and for some reason it's just not registering.
DB query directly in the mysql cli (which is working perfectly and producing the results I want):
SELECT AVG(TIMESTAMPDIFF(MINUTE, `on_scene_time`, `clear_time`)) FROM(SELECT `on_scene_time`, `clear_time` FROM `volunteer_dispatches`) temp
Laravel code to bring that query to a front-end:
\DB::statement( \DB::raw('SELECT AVG(TIMESTAMPDIFF(MINUTE, `on_scene_time`, `clear_time`)) FROM(SELECT `on_scene_time`, `clear_time` FROM `volunteer_dispatches`) temp') );
Getting this result: Illuminate/Database/QueryException with message 'SQLSTATE[HY000]: General error: 1 no such column: MINUTE (SQL: SELECT AVG(TIMESTAMPDIFF(MINUTE, on_scene_time, clear_time)) FROM(SELECT on_scene_time, clear_time FROM volunteer_dispatches) temp)'
I also tried DB::select
Level 51
Please or to participate in this conversation.