Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6194871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:22:07+00:00 2026-05-24T03:22:07+00:00

When I insert a new row the treeId column is always 1. The treeId

  • 0

When I insert a new row the treeId column is always 1.
The treeId column is not included in the insert statement.

What could be causing it to not increment?

My table code is

CREATE TABLE `users` (
  `uuid` varchar(36) NOT NULL,
  `parentUuid` varchar(36) DEFAULT NULL,
  `treePath` text,
  `treeId` int(11) NOT NULL AUTO_INCREMENT,
  `firstName` varchar(50) NOT NULL,
  `lastName` varchar(50) NOT NULL,
  `email` varchar(255) NOT NULL,
  `salt` varchar(40) NOT NULL,
  `password` varchar(40) NOT NULL,
  `state` enum('subscribed','registered','banned') NOT NULL,
  `dobMonth` int(11) DEFAULT NULL,
  `dobYear` int(11) DEFAULT NULL,
  `dateSubscribed` datetime DEFAULT NULL,
  `dateRegistered` datetime DEFAULT NULL,
  `gender` enum('unspecified','male','female') NOT NULL DEFAULT 'unspecified',
  `dd` float DEFAULT '0',
  `mainRegion` int(11) DEFAULT NULL,
  PRIMARY KEY (`uuid`,`treeId`),
  KEY `parentid` (`parentUuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:22:08+00:00Added an answer on May 24, 2026 at 3:22 am

    Found the answer (Documentation)

    For MyISAM and BDB tables you can specify AUTO_INCREMENT on a
    secondary column in a multiple-column index. In this case, the
    generated value for the AUTO_INCREMENT column is calculated as
    MAX(auto_increment_column) + 1 WHERE prefix=given-prefix. This is
    useful when you want to put data into ordered groups.

    CREATE TABLE animals (
        grp ENUM('fish','mammal','bird') NOT NULL,
        id MEDIUMINT NOT NULL AUTO_INCREMENT,
        name CHAR(30) NOT NULL,
        PRIMARY KEY (grp,id)
    ) ENGINE=MyISAM;
    
    INSERT INTO animals (grp,name) VALUES
        ('mammal','dog'),('mammal','cat'),
        ('bird','penguin'),('fish','lax'),('mammal','whale'),
        ('bird','ostrich');
    
    SELECT * FROM animals ORDER BY grp,id;
    Which returns:
    
    +--------+----+---------+
    | grp    | id | name    |
    +--------+----+---------+
    | fish   |  1 | lax     |
    | mammal |  1 | dog     |
    | mammal |  2 | cat     |
    | mammal |  3 | whale   |
    | bird   |  1 | penguin |
    | bird   |  2 | ostrich |
    

    So because I had a joint key on uuid (which is always unique) and on treeId (which is the auto-increment) then it was creating a new increment group each time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whenver I try to insert a new row into my table manually, I get
How to insert new row using PHP in SQLITE in table /var/drk.db and to
I'm trying to alter a table to add a new column, then insert a
I'm creating a stored function which should insert new row to table. In this
I want to insert a new row into a msaccess table using the following
I want to insert a new row in a table say 'table1' with autogenerated
I know how to insert a new row into a table that has a
I am trying to create a trigger wherein it will insert a new row
I'm trying to insert a new row in the table but I'm getting below
I want to insert a new row in my table. I want the id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.