Reputation: 3
i got an error while im trying to execute query views in mysql version 5.7.19
Here is my query :
CREATE ALGORITHM=UNDEFINED DEFINER=`acc_webdev`@`%` SQL SECURITY DEFINER VIEW `view_dash_total` AS
SELECT
COUNT(0) AS `jumlah`,
SYSDATE() AS `tanggal`
FROM `table_laporan`
WHERE (STR_TO_DATE(`table_laporan`.`dt_added`,'%d-%m-%Y') < (SYSDATE() + INTERVAL - (1)DAY))$$
and got this error:
ERROR 1064 (42000): 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 '$$' at line 6
but in mysql 5.1.25, there's no error when i execute the query above
please help me out
Upvotes: 0
Views: 2930
Reputation: 14678
Either prepend your DDL with DELIMITER $$
or just change your delimiter to ;
.
Read more about delimiters here
Upvotes: 0
Reputation: 1300
Try This:
CREATE VIEW `view_dash_total` AS
SELECT
COUNT(0) AS `jumlah`,
SYSDATE() AS `tanggal`
FROM `table_laporan`
WHERE (STR_TO_DATE(`table_laporan`.`dt_added`,'%d-%m-%Y') < (SYSDATE() + INTERVAL - (1)DAY));
Upvotes: 0