Reputation: 7034
I'm currently using:
SELECT MAX(id) FROM table
To discover the current id of a certain table, but i heard this can bring bad results. What is the proper way of doing that? Please, notice that i'm not INSERTING or DELETING anything before that query. I just want to know the current ID, without prior INSERT or DELETE.
Upvotes: 2
Views: 539
Reputation: 1219
You can use the following query:
SELECT id FROM table ORDER BY id DESC LIMIT 1;
Upvotes: 1
Reputation: 184
Perform the following SQL:
SHOW TABLE STATUS LIKE 'TABLENAME'
Then check field AUTO_INCREMENT
Upvotes: 2