Jump to content

When I do ORDER BY ID DESC I am missing a record


pioneerx01

Recommended Posts

I have a query that shows me all the records in the table. Nothing I have not done before. I have 20 unique records there at this time.

When I run a query to show me all records in the table it displays all 20 records.

If I tell it to order them ASC by ID it shows records 1-20 as it should.

If I tell it to order them DESC by ID is shows records 19-1, but not 20. I have to add record 21 to see record 20 in the query, but I will not see record 21.

 

WHY?

 

 

Link to comment
Share on other sites

Your php code is probably fetching and discarding one row or your query is doing something to cause one row to not be matched.

 

If you want help with something you are doing that does not work, you must post the query and code responsible for the symptoms.

Link to comment
Share on other sites

Sorry ryanweekly it was not as easy, I have tried that too.

 

PFMaBiSmAd you are correct I had this running :

 

$result = mysql_query('SELECT * FROM galleries ORDER BY id DESC');
$row = mysql_fetch_array($result);
while($row = mysql_fetch_array($result)){

 

and I need only this:

 

$result = mysql_query('SELECT * FROM galleries ORDER BY id DESC');
while($row = mysql_fetch_array($result)){

 

Stupid me ....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.