Error in MYSQL query while fetching users

Question:

There is a request to the database

SELECT
  *
FROM
  "rovno"
WHERE
  ("years" BETWEEN 19 AND 60) "message" = 1
ORDER BY
  "rate" DESC
LIMIT 0,20

He selects from the table columns with data of users who have open drugs and age from 19 to 60 and then sorted by rating through ORDER BY DESC .

Where is the error in this request?

Answer:

You use double quotes to frame the names of tables and fields – this is not true, you should use backward quotes (these quotes are needed if you have names that match reserved keywords)

SELECT
  *
FROM
  `rovno`
WHERE
  (`years` BETWEEN 19 AND 60) AND `message` = 1
ORDER BY
  `rate` DESC
LIMIT 0, 20

In addition, the WHERE is missing the AND keyword (or maybe OR ?) Between the conditions ("years" BETWEEN 19 AND 60) and "message" = 1 .

Scroll to Top