test the query in another tool. The syntax seems wrong although you have not said what the other database is.
you need a where statement I think
select avgvalue, logtime from 2ndDB.mytable where logtime between ? and ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm confused at Laravel's query DB. Here is my code:
collect(DB::connection('2ndDB')->select('select avgvalue, logtime from 2ndDB.mytable where logtime =?',array('14:38')));
It does work on and return the right value. However, once I change the SQL statement with 'between' condition, down here:
collect(DB::connection('2ndDB')->select('select avgvalue, logtime from 2ndDB.mytable between logtime =? and ?',array('14:38','15:00')));
It would get error. May I ask how to fix it?
Note: I am query the outside database that the 'mytable' is not declared in the mode/database/migration part. So, I use the (DB:connection()) in this way for query.
test the query in another tool. The syntax seems wrong although you have not said what the other database is.
you need a where statement I think
select avgvalue, logtime from 2ndDB.mytable where logtime between ? and ?
Please or to participate in this conversation.