Reputation: 95
I have the code but not the local host that an error I can't understand help MYSQL 5.7.21 INNODB Code:
$sql = DB::select('
SELECT
(case when (CAST(to as time) <= CAST("'.$time.'" as time) and
CAST(do as time) >= CAST("'.$time.'" as time) or
(to is null and do is null))
THEN
1
ELSE
0
END) as working
FROM
franchises
');
Error:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'to as time) <=
CAST("10:15" as time) and CAST(do as time) >= CAST("10:15" as tim' at
line 2 (SQL:
Upvotes: 0
Views: 463
Reputation: 34231
To
is a reserved word in MySQL, therefore you need to include it in backticks:
...case when (CAST(`to` as time)...
Upvotes: 3