0

I have sql query:

$query= "SELECT * FROM files ORDER BY id DESC LIMIT $from, $site WHERE custom > 0";

but not work, i have notice:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

What i do wrong?

1
  • Order by has to be after where.
    – Howard E
    Apr 6, 2019 at 21:16

1 Answer 1

2

You have the where clause of the query in the wrong place.

Your query should be written like this:

$query= "SELECT * FROM files WHERE custom > 0 ORDER BY id DESC LIMIT $from, $site";

As specified here https://dev.mysql.com/doc/refman/8.0/en/select.html in the MySQL reference.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.