I want to know if it is possible to make a mysql_query start art a certain row in the database.
I want to to start at row2 instead of row1
I want to know if it is possible to make a mysql_query start art a certain row in the database.
I want to to start at row2 instead of row1
Use the LIMIT clause, with a very large number (larger than your rowcount) for the max records returned. Normally, LIMIT is used to select a block of records, optionally beginning with an offset. In your case, you want all records after the offset so you have to fake it with a high maximum number.
UPDATE I just read the docs and LIMIT starts its offset at 0, so it should in fact be LIMIT 1, 99999
SELECT * FROM table ORDER BY id ASC LIMIT 1, 99999999999
On the other hand, if your first record has an identity column less than the second row, you can just do:
SELECT * FROM table WHERE id < 1;
In relational databases like MySQL rows do not have any default order. Seriously. Even if several SELECT * FROM table consecutive queries appear to sort results by insertion order.
You can, however, use the ORDER BY clause to order the rows of specific queries.
Additionally, the LIMIT clause allows further filtering.
Depends on what you're trying to do. You can't start at a certain row int he DB, but you can start at a certain row in the result set:
SELECT * FROM tbl_name LIMIT 2, 10000;
Of if you explicitly need to skip a row for some reason:
$skip = true;
while ($row = mysqli_fetch_assoc($res))
{
if ($skip)
{
$skip = false;
continue;
}
Or a variety of other solutions depending on your exact problem.