Posted By

cherbert on 09/29/09


mysql key primary composite

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


MySQL Insert Unique Reference

 / Published in: MySQL

MySQL Insert Unique Reference using MAX() to obtain latest value Alternate solution to using Composite Primary Keys which INNODB engine does not support.

  1. INSERT INTO jobs (companyid,clientref,jobid) VALUES (8,2,IFNULL((SELECT max(b.jobid)+1 FROM jobs b WHERE b.clientref=2),1) );

Report this snippet  

You need to login to post a comment.