MySQL Next Autoindex

They have: 45 posts

Joined: Feb 2002

I need to get the next autoindex of a table called 'threads' froma database called 'message_board'.

I've asked around, and no one seems to be able to give me a good answer, any help would be appreciated.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

try this:

SHOW TABLE STATUS FROM `message_board` LIKE 'threads';

this will return a list of fields including Auto_increment, which contains the value of the next auto_increment value.

mySQL Docs:
4.5.6.2 SHOW TABLE STATUS

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 45 posts

Joined: Feb 2002

Ah okay, thanks.

I heard that that might not be a very safe way to do things on something user intensive like a forum, because if two people request things right after another, they might get the same things, and then post things with the same thing... and... well... it's tough to explain.

Is this a safe way of doing things that you know of?

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Why do you want the next auto_increment number?
What do you plan on doing with it?

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.