-3

I have a problem, trying to sort my Select request -

SELECT * FROM `table_name`  OREDER BY `score` DESC LIMIT 10 ; 

I get error #1064:

#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 'BY score DESC LIMIT 10' at line 1

But I realy don't know wats wrong ! Names and quotes are right, as I think... as this request works correctly:

INSERT INTO `table_name` (`uid`, `score`) VALUES ("'.$viewer_id.'","'.$uscore.'") ON DUPLICATE KEY UPDATE `score` = "'.$uscore.'";'; 

Can somebody help me!!??

P.S sorry for my English(

hjpotter92
  • 78,589
  • 36
  • 144
  • 183

2 Answers2

2

it's ORDER not OREDER

SELECT * FROM table_name ORDER BY score DESC LIMIT 10

As a sidenote, the query is vulnerable with SQL Injection if the value(s) of the variables came from the outside. Please take a look at the article below to learn how to prevent from it. By using PreparedStatements you can get rid of using single quotes around values.

Community
  • 1
  • 1
John Woo
  • 258,903
  • 69
  • 498
  • 492
1

You have a spelling error in your syntax it's 'ORDER BY' not 'OREDER BY' the correct syntax should be:

SELECT * FROM `table_name`  ORDER BY `score` DESC LIMIT 10 ;
Pratheek Rebala
  • 375
  • 2
  • 7