-1

i have a query for join selection form two table when i run it on localhost xampp server it work well but in the domain server it didnt work and i cant point where is the error

here is the problem

<b>Fatal error</b>:  Uncaught PDOException: 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 'LIMIT 3) AS chapname,
   GROUP_CONCAT(chapters.chaptername ORDER BY chapters.cha' at line 2 in /home/vol16_1/epizy.com/epiz_29037568/htdocs/includes/functions/function.php:27
Stack trace:
#0 /home/vol16_1/epizy.com/epiz_29037568/htdocs/includes/functions/function.php(27): PDOStatement-&gt;execute()
#1 /home/vol16_1/epizy.com/epiz_29037568/htdocs/index.php(63): getnow()
#2 {main}
  thrown in <b>/home/vol16_1/epizy.com/epiz_29037568/htdocs/includes/functions/function.php</b> on line <b>27</b><br />

and here is the selection query

SELECT DISTINCT novel.NovelID, novel.NovelName,novel.NovelImage,
  GROUP_CONCAT(chapters.chapternumber ORDER BY chapters.chapterID DESC LIMIT 3) AS chapname,
   GROUP_CONCAT(chapters.chaptername ORDER BY chapters.chapterid DESC LIMIT 3) AS chpnum,
    chapters.chapterID FROM novel INNER JOIN
   chapters ON novel.NovelID = chapters.NovelID AND Date(chapters.chapterDate) >= CURDATE()  GROUP BY novel.NovelName
  • You just be using mariadb on your localhost and mysql (or mariadb version earlier than 10.3.3), which do not support limit clause within group_concat. You must use the same versions in your dev and production environmemts, otherwise you can bump into issues like this one. Pls also note that mariadb is **NOT** mysql! The two products forked 13 years ago! – Shadow Jul 22 '21 at 20:22

1 Answers1

0

Review the documentation here: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat

The GROUP_CONCAT() function does not support a LIMIT clause.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828