tags:

views:

97

answers:

3

I have these tables: http://stackoverflow.com/questions/2104063/my-final-mysql-db-could-someone-check-if-the-tables-are-correctly-made

How can I make an Insertion of an ad here?

Is join used on insert also?

Thanks

Clarification: I need to insert values into multiple tables here, and don't know how to do it else than using multiple INSERT INTO statements.

So I wonder if there is anyway to make just ONE statement (one line) and use JOIN to INSERT?

A: 

I don't understand your first question about the ads. As for the second, JOIN will not be used on a standard table unless you are using it in an INSERT...SELECT statement, which you very likely aren't.

Jon
I wonder how to insert an ad into my database, and the link is the database I am referring to. How should I formulate the INSERT statement into this db?
Camran
+1  A: 

As far as I'm aware of, you can't INSERT data into multiple tables Within one plain SQL statement.

There are many database abstraction frameworks out there which can do something like that (DOCTRINE TO THE RESCUE!!) but thats a whole other story.

SQL for it self it not capable of such things.

Techpriester
I found out just now, that TRANSACTIONS can be used, seem a little more work though! Thanks!
Camran
Transactions are used to make a "group" out of individual SQL statements that can be specially secured against loss of data integrity and can be rolled back easily if something goes wrong for example.
Techpriester
+1  A: 

No it's not possible with an INSERT statement to insert into multiple tables. But you could use a stored procedure that would nicely batch the various inserts, and the application would have only one SQL command to emit.

ggiroux