Allows say I've the next table known as assets using the following fields:
id | job_id | title
I must use id and job_id because the primary secrets. job_id may be the foreign key. The id area is auto incremented. Wouldso would I recieve id to begin incrementing at if there's no row with similar job_id. If there's a row with similar job_id then increment id by 1 and so forth?
The end result I'm searching for is really a table that appears such as this:
id | job_id | title 0 1 hi 1 1 hello 2 1 goodbye 0 2 hi 1 2 hello
Now allows say a brand new row with job_id = 3 is added. The id area should start auto incrementing from again.
If you are using the MyISAM storage engine, the car-increment column inside a multi-column primary key begins over and done with each new value within the non-auto-increment column.
Should you mean particularly beginning at zero, the documentation states auto_increment begins at 1 by design. However, "When the NO_AUTO_VALUE_ON_ZERO SQL mode is enabled, you are able to store in AUTO_INCREMENT posts as without producing a brand new sequence value."
Should you mean to recycle amounts which are no more utilized in the table, which should happen instantly, when the removed amounts were the greatest number used.