Multiple Line Queries
Moderator: General Moderators
Multiple Line Queries
If I have a textarea similar to phpMyAdmin's where people can paste a mySQL dump, or write a query that goes over serveral lines for example two inserts entered one after the other like this:
INSERT INTO table (id) VALUES ('1')
INSERT INTO table (id) VALUES ('2')
INSERT INTO table (id) VALUES ('3')
How do I get mysql to accept it as a query? I tried seperating with semi-colons and it throws an error at me, is there a valid way of doing this? I also looked at the phpMyAdmin source but I couldn't find what I was looking for.
INSERT INTO table (id) VALUES ('1')
INSERT INTO table (id) VALUES ('2')
INSERT INTO table (id) VALUES ('3')
How do I get mysql to accept it as a query? I tried seperating with semi-colons and it throws an error at me, is there a valid way of doing this? I also looked at the phpMyAdmin source but I couldn't find what I was looking for.
Yes but the thing is that this doesn't work...Oromian wrote:They are supose to end with a semi-colon: ;
Code: Select all
INSERT INTO table VALUES("hello","1");
INSERT INTO tabl2 VLUES("hi","1");hmm,
here is a copy of a working .SQL file i have...
maybe there is a typo somewhere in your code... 
here is a copy of a working .SQL file i have...
Code: Select all
INSERT INTO lottery
( num, ticket, cash ) VALUES
( 0 , 0 , 100000000), #current jackpot
( 0 , 1 , 100000000), #last jackpot
( 0 , 2 , 0 ),
( 0 , 3 , 0 ),
( 0 , 4 , 0 );
INSERT INTO lottery2
( num, ticket, cash ) VALUES
( 0 , 0 , 100000000), #current jackpot
( 0 , 1 , 100000000), #last jackpot
( 0 , 2 , 0 ),
( 0 , 3 , 0 ),
( 0 , 4 , 0 );do thoses two typos affect the execution?Takuma wrote:Yes but the thing is that this doesn't work...Oromian wrote:They are supose to end with a semi-colon: ;
Code: Select all
INSERT INTO table VALUES("hello","1"); INSERT INTO tabl2 VLUES("hi","1");
eh????
If I do this
This creates an error! 
If I do this
Code: Select all
<?php
mysql_query("INSERT INTO members ('user1','password2'); INSERT INTO members ('user2','password3'); ");
?>