Can I use a MySQL stored procedure (or some other means) to insert a series rows that reference to-be-created rows from another table? -
i have mysql database tracking projects. each project has 1 or more categories, , each category has 1 or more tasks.
-------- projects -------- id name 1 first project ---------- categories ---------- id projectid name 1 1 first category project 1 2 1 second category project 1 ---------- tasks ---------- id projectid categoryid name 1 1 1 first tasks category 1, project 1 2 1 1 second task category 1, project 1 3 1 2 first task category 2, project 1
(i know projectid not required tasks table.)
when user initiates new project, i'd include dozen or default category rows (and associated default tasks).
needless say, can't execute purely canned insert instructions, because need know id numbers each newly inserted project before insert categories, need know each new category's id before insert tasks.
of course can series of queries, executed php, i'm wondering if can handled either stored procedure or sort of fancier-than-i-know-how-to-write mega query.
Comments
Post a Comment