Auto incrementing.

Post here if you need help with SQL.
Post Reply
Torniquet
Posts: 52
Joined: Sun Jun 19, 2011 8:10 am
Contact:

Auto incrementing.

Post by Torniquet »

through phpmydamin is there any way to set up a table so that a column will increment accourding to the setting of another column?

so for eg?

column A contains ENUM a,b,c and column B contains INT

column B needs to be auto incremented.

so if there were 4 a's set in A and 2 b's, i inserted another row setting A to be 'b', can i get B to auto increment according to what value would be next for the b's?

make sense? lol.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Auto incrementing.

Post by jacek »

Torniquet wrote:make sense? lol.
Not really ;)
Torniquet wrote:through phpmydamin is there any way to set up a table so that a column will increment accourding to the setting of another column?
No, but can you not make the comparison with php and decide on the value to insert ? Or could you not ge the same data using mysql functions when selecting ?
Image
Torniquet
Posts: 52
Joined: Sun Jun 19, 2011 8:10 am
Contact:

Re: Auto incrementing.

Post by Torniquet »

well i have a mysql driven dynamic menu system. (there is a reason for it, and it is easier than making it static for its use lol)

The idea is that A would be the menu selector, and B is the items position. so if i am putting in menu items, the position needs to be different. Just thought it might be easier to set phpmyadmin to do it rather than faf about with a script.

I will have to make one earlier than intended now lol.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Auto incrementing.

Post by jacek »

phpmyadmin is just an interface to the mysql server, it cant do anything. There may be some obscure MySQL feature that lets you do this but I don't know of it.
Image
Post Reply