user3427569
user3427569

Reputation: 1

Wrong result for "ID" when using SELECT query mysql

I have written a small piece of code to grab information from mysql database

the query I'm using:

SELECT id, title FROM mydb ORDER BY id DESC limi 0,4;

this code works perfectly on my local webserver but when I upload it to a public server it works but the id associated with all the results is the same and is equal to some wiered number like 201454672 which is wrong.

I checked the database everything there is okay, the data in place and their ids are true only select produces the wrong ID, everything else is okay

what the heck could cause this problem ?

Upvotes: 0

Views: 327

Answers (2)

Nikunj Kabariya
Nikunj Kabariya

Reputation: 840

As i can found in your query you made a silly mistake.Please correct it. Change

SELECT id, title FROM mydb ORDER BY id DESC limi 0,4;

to

SELECT id, title FROM mydb ORDER BY id DESC limit 0,4;

If it is still not working then change Datatype of id to BIGINT and try.

Upvotes: 1

Elixir Techne
Elixir Techne

Reputation: 1856

Please check the table structure. Verify the Size of id field.

It seems that the data in you live server has id value beyond its limit.

For data type and its limit, refer MySQL Wiki

Upvotes: 0

Related Questions