0

With Mysql tables like

table_main
    id
    firstname
    lastname

table_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

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Not that I'm aware of.

Comments

0

Nope, but you can create a procedure and then call with it.

http://dev.mysql.com/doc/refman/5.1/en/create-procedure.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.