开发者

Mysql insert query

开发者 https://www.devze.com 2023-01-10 20:46 出处:网络
With Mysql tables like table_main id firstname lastname t开发者_Python百科able_type id table_main_id table_type_id

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

0

精彩评论

暂无评论...
验证码 换一张
取 消