[MySql] Creating multiple rows at once.
#1

Hello. Is it possible to create multiple rows at once/with one query. The rows have to be with their default vaules, only different IDs ofcourse. Something like
Код:
INSERT INTO `entrances` (`id`) VALUES between (1) and (1000);
if it even exists.
Reply
#2

pawn Код:
format(query, sizeof(query), "INSERT INTO `entrances`(id, var1) VALUES(0, '%d', '%d',)" id, var);
Reply
#3

I mean a sql query. Not needed for script. I just want to create tons of default rows from id 1 to id 1000.
Reply
#4

You can just put the statement in a loop for executing the statement how much times you want ...
Reply
#5

Quote:
Originally Posted by -=Dar[K]Lord=-
Посмотреть сообщение
You can just put the statement in a loop for executing the statement how much times you want ...
If I knew how to create a loop, i wouldnt ask this question.
Reply
#6

Quote:
Originally Posted by Unri
Посмотреть сообщение
If I knew how to create a loop, i wouldnt ask this question.
Fine , just give me the table name , the var you want to set , and other things which you want to put in that creation of rows once at a time
Reply
#7

Quote:
Originally Posted by -=Dar[K]Lord=-
Посмотреть сообщение
Fine , just give me the table name , the var you want to set , and other things which you want to put in that creation of rows once at a time
Table name is "entrance". All i need is to have rows from id 1 to id 1000 with default values. Nothing more. Just make it insert id 1, id 2, id 3.
Reply
#8

hmm so ... the ids are like
id 1 , id 2 , id 3 are coloums and 1 - 1000 are rows?

EDIT: Whats the default Value?
Reply
#9

Quote:
Originally Posted by -=Dar[K]Lord=-
Посмотреть сообщение
hmm so ... the ids are like
id 1 , id 2 , id 3 are coloums and 1 - 1000 are rows?

EDIT: Whats the default Value?
Each row has its own id. 555th row will have id = 555. 839th row will have id = 839. Default values are the ones specified for each column in table options.
Reply
#10

fine .... i will give you the loop code fix it accordingly

pawn Код:
new string[256];
for(new i = 1; i <= 1000; i++)// Will take a loop throught 1000 numbers
{
    format(string,sizeof(string),"INSERT INTO entrance(id) VALUES(%d)",i);//will set the number as per as loop goes
    mysql_query(string);//will do the mysql query part
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)