Reputation: 11
I created the following query in MySQL 8.0, but when I try to add using phpMyAdmin I get the following error:
MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH RECURSIVE t as ( select CAST(DATE_FORMAT(selectedDT ,'%Y-%m-01') as...' at line 3
question: How can I convert the query to MariaDB?
the query:
CREATE DEFINER=`root`@`localhost`PROCEDURE`stats_getbycurrmonth\`(in selectedDT DateTime)
BEGIN
SET @lastday = last_day(CONCAT(year(selectedDT),'-',month(selectedDT),'-01'));
WITH RECURSIVE t as (
select CAST(DATE_FORMAT(selectedDT ,'%Y-%m-01') as DATE) as dt
UNION
SELECT DATE_ADD(t.dt, INTERVAL 1 DAY) FROM t WHERE DATE_ADD(t.dt, INTERVAL 1 DAY) \<= @lastday
)
SELECT Y.*, R.* FROM
(SELECT count(\*) as COUNT, date(dataora) as DAY FROM dinaromdb.loguri where nivel like '%ERROR%' group by date(dataora) order by date(dataora)
) R RIGHT JOIN
(select date(dt) as Days, dayname(dt) as DayName FROM t
) Y on R.Day = Y.Days GROUP BY Y.Days, Y.DayName, R.COUNT;
END
execution: call dinaromdb.stats_getbycurrmonth('2024-11-05');
what I tried: Based on this article I tried to remove the "recursive" keyword, but without luck.
Upvotes: 0
Views: 55