1

I have recently restored my joomla website and it was working perfectly fine, but suddenly I am receiving the following error:

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 ') ORDER BY `registerDate` DESC LIMIT 20' at line 1
SQL=

SELECT * FROM `jnx_users` WHERE `block`='0' AND `id` NOT IN() ORDER BY `registerDate` DESC LIMIT 20

An error has occurred while processing your request.

You may not be able to visit this page because of:

  • an out-of-date bookmark/favourite
  • a mistyped address
  • a search engine that has an out-of-date listing for this site
  • you have no access to this page

Go to the Home Page

Home Page

If difficulties persist, please contact the System Administrator of this site and report the error below.

2
  • Sorry but this isn't really enough for someone to be able to help… a link to the website would probably help. More details about when it occurs e.g. any page of the website, just the home page or in a specific circumstance (like trying to login to the front-end or to /administrator)
    – Craig
    Commented Feb 16, 2016 at 0:33
  • @Amirali If you provide your php code that is building the query, we can suggest some specific improvements that will avoid this error regardless of the dynamic data being supplied. Commented Jul 23, 2018 at 3:20

2 Answers 2

2

While using IN() or NOT IN() clause comma (,) separated values or empty string must be passed as parameter.

For example: IN(1,2,3) OR IN('') OR IN('a', 'b', 'c')

1
  • It should be pointed out that if you are going to pass a comma separated list to your IN array that it should be a quoted list unless you are working strictly with integers of whole numbers. NOT IN (1,2,3) will work... NOT IN (a,b,c) results in a sql error. I know your answer shows that, but some explanation would be nice for those who may not know. I normally just quote all of my IN array queries like this to be safe.
    – Terry Carter
    Commented Feb 17, 2016 at 5:11
1

The problem you are having is due to the id NOT IN() filter in your query. You can't use NOT IN() without an array being passed inside it, even if it is an empty array. Change your query to this:

SELECT * FROM jnx_users WHERE block='0' AND id NOT IN('') ORDER BY registerDate DESC LIMIT 20

Notice the 2 single quotations inside the NOT IN('') portion of the statement. That fixes this issue. You can also remove the id NOT IN() AND portion of the query if you are not going to filter any ids with it.

Your Answer

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

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