It is necessary to make a sample like this:

SELECT id,title,data FROM #__table WHERE state=1 AND id NOT IN ('" . $arrIds2NAr . "') ORDER BY RAND() LIMIT 3 

where $arrIds2NAr is 1,23,56,89,11,22,45

It turns out that there is a sampling limit. Everything seems to be done as it should. When an AJAX request is loaded, the data is loaded onto the page and a new ID comes up in NOT IN which DOES NOT HAVE to be included in the request, BUT THEY HAVE EVERYTHING. Ie, for example, in $arrIds2NAr there is ID = 25, but it still comes across in the sample. How to fix it?

  • 2
    for example, $ arrIds2NAr has ID = 25, but it still comes in the sample. Show query text AFTER the substitution of parameters into it. The most likely reason is that there are no single quotes in the query text that turn the inserted list into a single string literal. Ps. But LIMIT is not exactly to blame here ... - Akina
  • SELECT id , title , item_data FROM #__content WHERE state = 1 AND id NOT IN ('41, 191,1,155,231,141,14,35,103,44,159,145,676 ') - Inverser
  • one
    Here ... ID is checked for occurrence not in the list of 14 numerical values, but in the list of one long string literal. Delete quotes. - Akina
  • one
    so to speak. @Akina looked like in the water :) - teran
  • one
    Requests do not write on a certain mystical whim. And do not debug the method of scientific spear. Any construction should be logically justified - and including. based on strict syntax compliance. - Akina

0