I have two MySQL tables, jobs
and job-parts
for which there are several job parts for each job referenced back using a job_id
column.
The jobs
table has the normal auto-increment on the id
column which I'm using as the job number. So currently I pull the job parts out like follows:
SELECT jobs.id, job_parts.id FROM jobs,job_parts WHERE job_parts.job_id = jobs.id;
What I need to do is set up some sort 'auto increment' on the job_parts
table, but one that resets for each different id on the first table, resulting in combined job references that look like
1.1, 1.2, 1.3,
2.1, 2.2, 2.3, 2.4
3.1, 3.2 ... and so forth.
Ideally I'd like to be able to delete parts from the second table and the part id
column to retain the numbers that were originally assigned when the parts were inserted, just like auto increment does normally.
Anyone know a nice clean way to do this with a SQL statement?