Possible Duplicate:
mysql two column primary key with auto-increment
I've got the following table with a UNIQUE
key over two columns:
+--------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| pa_id | int(6) | NO | PRI | NULL | |
| FK_languages | tinyint(2) | NO | PRI | NULL | |
| pa_attribute | varchar(255) | NO | | NULL | |
+--------------+--------------+------+-----+---------+-------+
Right now, I've got the following entries:
+-------+--------------+--------------+
| pa_id | FK_languages | pa_attribute |
+-------+--------------+--------------+
| 1 | 1 | white |
| 1 | 2 | weiß |
+-------+--------------+--------------+
Let's say, I want to insert a new entry "black" with FK_languages = 1
... what is the best practice to auto increment
col "pa_id" that it will look like this:
+-------+--------------+--------------+
| pa_id | FK_languages | pa_attribute |
+-------+--------------+--------------+
| 2 | 1 | black |
+-------+--------------+--------------+
NOTE Unfortunateley I cannot use the TRIGGER
function of MySql. Is it possible to do this nevertheless via MySql? I would like to avoid doing this via my scripting-language (PHP).
EDIT:
It seems I can only solve this issue via my query in PHP. The assumed duplicate thread only offers two solutions: MyISAM or Innodb + trigger. Neither will work with me.