Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Works in MYSQL 5.7, Syntax Error in MYSQL 8.0

Works in MYSQL 5.7, Syntax Error in MYSQL 8.0

Scheduled Pinned Locked Moved Database
databasemysqlgame-devsysadmincollaboration
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Douglas Kirk 2022
    wrote on last edited by
    #1

    Hello My query to get a ranked leaderboard works on MYSQL 5.7 but gives me errors now that I upgraded to MYSQL 8.0

    mysql> SELECT username,score,level, FIND_IN_SET(score,(SELECT GROUP_CONCAT(score ORDER BY score ASC)FROM highscore WHERE game = 0 AND level = 4 AND user = 10 )) AS rank FROM highscore WHERE game = 0 AND level = 4 AND user = 1 ORDER BY rank LIMIT 10;

    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 'rank FROM highscore WHERE game = 0 AND level = 4 AND user = 1 ORDER BY rank LIMI' at line 1 Any ideas? Thank you Team!

    J R 2 Replies Last reply
    0
    • D Douglas Kirk 2022

      Hello My query to get a ranked leaderboard works on MYSQL 5.7 but gives me errors now that I upgraded to MYSQL 8.0

      mysql> SELECT username,score,level, FIND_IN_SET(score,(SELECT GROUP_CONCAT(score ORDER BY score ASC)FROM highscore WHERE game = 0 AND level = 4 AND user = 10 )) AS rank FROM highscore WHERE game = 0 AND level = 4 AND user = 1 ORDER BY rank LIMIT 10;

      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 'rank FROM highscore WHERE game = 0 AND level = 4 AND user = 1 ORDER BY rank LIMI' at line 1 Any ideas? Thank you Team!

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      According to the following 'rank' was added as a keyword in MySQL 8 MySQL :: MySQL 8.0 Reference Manual :: 9.3 Keywords and Reserved Words[^]

      D 1 Reply Last reply
      0
      • J jschell

        According to the following 'rank' was added as a keyword in MySQL 8 MySQL :: MySQL 8.0 Reference Manual :: 9.3 Keywords and Reserved Words[^]

        D Offline
        D Offline
        Douglas Kirk 2022
        wrote on last edited by
        #3

        Thank you so much. Simply changed "rank" to "ranklist" and it has resolved the issue.

        1 Reply Last reply
        0
        • D Douglas Kirk 2022

          Hello My query to get a ranked leaderboard works on MYSQL 5.7 but gives me errors now that I upgraded to MYSQL 8.0

          mysql> SELECT username,score,level, FIND_IN_SET(score,(SELECT GROUP_CONCAT(score ORDER BY score ASC)FROM highscore WHERE game = 0 AND level = 4 AND user = 10 )) AS rank FROM highscore WHERE game = 0 AND level = 4 AND user = 1 ORDER BY rank LIMIT 10;

          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 'rank FROM highscore WHERE game = 0 AND level = 4 AND user = 1 ORDER BY rank LIMI' at line 1 Any ideas? Thank you Team!

          R Offline
          R Offline
          Richard Deeming
          wrote on last edited by
          #4

          Perhaps you should get together with your classmate / colleague: I need to generate rank in mysql v5.7.31[^]


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups