Welcome Guest, Not a member yet? Register   Sign In
INSERT ALL INTO equivalent...
#1

[eluser]fouadami[/eluser]
I just wanna insert some values in more than one table in just one command of SQL. I used to do that with "INSERT ALL INTO" command of MSSQL but I don't know the equivalent statement in MySQL, Is there one in MySQL?!

Thank you for your help Smile
#2

[eluser]Mirage[/eluser]
I don't think your question has anything to do with CI. You should post in the 'Code and Application Development' forum.

The mysql manual is at 'http://dev.mysql.com/doc/'

Cheers -
m
#3

[eluser]fouadami[/eluser]
Ok then...
#4

[eluser]chandrajatnika[/eluser]
Code:
INSERT INTO yourtable(field1,field2) VALUES('$field1_value1','$field2_value1'),('$field1_value2','$field2_value2'),('$field1_value3','$field2_value3'),('$field1_value4','$field2_value4');

after your execute this query, then 4 rows will affected
#5

[eluser]fouadami[/eluser]
Well thank you very much but this query is for inserting multiple rows in just ONE table! INSERT ALL inserts rows in MULTIPLE tables...
#6

[eluser]chandrajatnika[/eluser]
Ups..i'm sorry I didn't read your question carefully but when you want to add rows in multiple table you must use transaction mode... http://www.codeignitor.com/user_guide/da...tions.html
#7

[eluser]fouadami[/eluser]
Yes, transaction mode is one way but it doesn't support multiple tables in just one query. I think there's no INSERT ALL command equivalent in mysql.




Theme © iAndrew 2016 - Forum software by © MyBB