mysql - Insert values with auto-increment foreign keys -


i have database 3 tables: matrix, mark , matrix-mark (the relationship between matrix , mark n-n).

here attributes of each one:

matrix: mx_id (auto-incremented); name; mark: mk_id (auto-inc); name; color; matrix-mark: mk_id (fk); ma_id(fk).  

for example, how insert multiple marks associated same matrix? i'm getting values through php post.

thanks in advance.

in php on inserting record u can last inserted id. there function this.

mysql_query("insert matrix(name) values ('deepak')"); $matrix_id = mysql_insert_id();  mysql_query("insert marks(name,color) values ('deepak','white')"); $marks_id = mysql_insert_id(); // u can insert these 2 id in third table..  

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -