Mysql insert query
With Mysql tables like
table_main
id
firstname
lastname
t开发者_Python百科able_type
id
table_main_id
table_type_id
table_type
id
typename
can a single sql insert query be contructed to run once with
fields: firstname, lastname, typename
values: john,doe,mytypename
INSERT INTO table_name (firstname, lastname, typename) VALUES (john, doe, mytypename)
won't work because you're trying to insert into multiple tables at once.
My suggestion would be to make a stored procedure that takes arguments firstname, lastname, and typename and then does the proper inserts.
Not that I'm aware of.
Nope, but you can create a procedure and then call with it.
http://dev.mysql.com/doc/refman/5.1/en/create-procedure.html
精彩评论