How to do Select all of the ids of a table except the first 2?

-1

I need to make a select in mysql of all users of a table, however I can not 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 did not help. I can not update my SQL so I can not use LIMIT, IN, ALL, ANY, and SOME. Does anyone know in any way? If there is another way you can tell me too.

    
asked by anonymous 19.11.2018 / 01:03

1 answer

1

If you are using PHP you can create a query that returns the number -2 (first two rows) of the record and use the value obtained to call the results, except for the first two rows

  

Edited Answer

<?php
//carrega arquivo de conexão do banco
include 'dbConfig.php';
?>


<?
// conta registros
$queryTotal = $db->query("SELECT count(id)-2 as id FROM tabela");
?>
<?php foreach($queryTotal as $row) : ?> 
<?php endforeach ?>

<!-- cria variavel de quantidade de registros -2 -->
<?$total = $row['id'];?>

<!-- chama registros menos os 2 primeiros usando a variável gerada acima -->
<?
$query = $db->query("SELECT id FROM tabela order by id DESC LIMIT $total");
    while($row = $query->fetch_assoc()){ 

} ?>

            <!--  imprime valores na tela-->
            <?php foreach($query as $row) : ?> 
            <?php echo $row['id']; ?></p>
            <?php endforeach ?> 
    
19.11.2018 / 02:04