vendredi 22 janvier 2016

sql BETWEEN in Laravel/Lumen

In the documentation for laravel they have the below;

The whereBetween method verifies that a column's value is between two values:

$users = DB::table('users')->whereBetween('votes', [1, 100])->get();

But what if I want to find out if a value is between two column's in my DB?

This is my raw sql

SELECT a.*, b.name FROM restaurants a, restaurant_class b
WHERE a.restaurant_class_id = b.id
AND '$d' = CURRENT_DATE
AND '$t' BETWEEN a.saturday_ot AND a.saturday_ct
ORDER BY id DESC 

saturday_ot and saturday_ct are TIME column's in my DB and $t is a time var so I want to check if the time is in between the the times in both columns.

Any help appreciated.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Td4m2X
via IFTTT

Aucun commentaire:

Enregistrer un commentaire