-1
I need to make a select in mysql of all users of a table, but I cannot receive the first two users of the table and I need to do this without specifying id, since when more users are registered I need the first two not to appear. I tried some things like NOT EXISTS (Other Select), but it didn’t help. I can’t update my SQL so I can’t use LIMIT, IN, ALL, ANY AND SOME. Does anyone know? If there’s another way you can tell me too.
Miguel, I don’t know if you read the other comment but, I tried to do what you said and even if sql gave me the message that can not use LIMIT. When I implemented the select you sent me, the page returned this error: ERRORSQLSTATE[42000]: Syntax error or access Violation: 1064 You have an error in your SQL syntax; check the manual that Corresponds to your Mariadb server version for the right syntax to use near '(SELECT Count(id) FROM bd_post ORDER BY id)' at line 1, you know what the problem would be?
– Marcus Lopes
Codes I’m using: $select = "SELECT Count(id) FROM bd_post ORDER BY id"; $Select2 = "SELECT * FROM bd_post ORDER BY id DESC LIMIT ($select)";
– Marcus Lopes
@Marcuslopes if you can put the full query in the question helps a lot, try to remove the parenthesis of
LIMIT ($select)
– Miguel Silva
Even removing the parentheses he gives the same error:
ERRORSQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT count(id) FROM bd_postagem ORDER BY id' at line 1
, basically what I need is for it to select all the fields of that table but ignoring all the fields of the last two ids.– Marcus Lopes
I’m using these two codes
$select2 = "SELECT count(id)-2 FROM bd_postagem ORDER BY id";
 $select3 = "SELECT * FROM bd_postagem ORDER BY id DESC LIMIT $select2";
– Marcus Lopes
I’m doing the query via Pdo:
try
 {

 $result2 = $conexao -> prepare($select3);
 $result2 ->execute();
 $contar2 = $result2 ->rowCount();

 if ($contar2 > 0) 
 {
 while ($show = $result2->FETCH(PDO::FETCH_OBJ))
 {
inside that while is the code to display what select bring me– Marcus Lopes
@Marcuslopes edited the answer, see if it helps you in any way, adapt to your query, tested here and worked well.
– Miguel Silva