Jump to content
  • 0
Pandoras

Adding multiple SQL Values using insert

Question

I'm not sure where to start but how to add multiple lines/value on SQL Insert Into.

I want to give rewards to a list of players with 3 different rewards 1 apple, 2 red potions, 30 flywings for example

I have a separate table for rewards to insert the items.

Here is my code:

set [email protected], query_sql("SELECT `account_id` FROM `cp_createlog` WHERE `reg_date` BETWEEN '2017-10-24 00:00:00' AND '2017-10-26 23:59:59'", [email protected]_id);
set [email protected]$ = "Testing";
setarray [email protected][0],14532,14592,14001,16682,2751,12210;
setarray [email protected][0],3,3,5,1,1,5;
for(set .i, 0; .i < getarraysize([email protected]); set .i,.i+1)
for(set .j, 0; .j < getarraysize([email protected]); set .j,.j+1)
for(set .k, 0; .k < getarraysize([email protected]); set .k,.k+1)
set [email protected]$, "( [email protected]_id[.i], '[email protected]$', [email protected][.j], [email protected][.k], 0)";
query_sql("INSERT INTO `event_rewards` ( `account_id`, `event_name`, `id`, `amount`, `value` ) VALUES '"+ [email protected]$ +"' ");

the [email protected]$ stands as the value input to the sql insert value.

how can i make [email protected]$ output to something this:

( 200000, 'Testing', 14532, 3, 0),
( 200000, 'Testing', 14592, 3, 0),
( 200000, 'Testing', 14001, 5, 0),
( 200001, 'Testing', 14532, 3, 0),
( 200001, 'Testing', 14592, 3, 0),
( 200001, 'Testing', 14001, 5, 0)

how can I make this possible?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
query_sql("INSERT INTO `event_rewards` ( `account_id`, `event_name`, `id`, `amount`, `value` ) VALUES ( "+.@account_id[.i]+", '"+.@eventname$+"', "+.@prize[.j]+", "+.@pamount[.k]+", 0) ");

 

  • Love 1
Link to comment
Share on other sites

  • 0
9 hours ago, Skorm said:
query_sql("INSERT INTO `event_rewards` ( `account_id`, `event_name`, `id`, `amount`, `value` ) VALUES ( "+.@account_id[.i]+", '"+.@eventname$+"', "+.@prize[.j]+", "+.@pamount[.k]+", 0) ");

 

Thank you!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.