Pandoras Posted October 30, 2017 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 16 Reputation: 3 Joined: 10/01/17 Last Seen: October 9, 2018 Share Posted October 30, 2017 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 .@count, 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'", .@account_id); set .@eventname$ = "Testing"; setarray .@prize[0],14532,14592,14001,16682,2751,12210; setarray .@pamount[0],3,3,5,1,1,5; for(set .i, 0; .i < getarraysize(.@count); set .i,.i+1) for(set .j, 0; .j < getarraysize(.@prize); set .j,.j+1) for(set .k, 0; .k < getarraysize(.@pamount); set .k,.k+1) set .@reward$, "( .@account_id[.i], '.@eventname$', .@prize[.j], .@pamount[.k], 0)"; query_sql("INSERT INTO `event_rewards` ( `account_id`, `event_name`, `id`, `amount`, `value` ) VALUES '"+ .@reward$ +"' "); the .@reward$ stands as the value input to the sql insert value. how can i make .@reward$ 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? Quote Link to comment Share on other sites More sharing options...
0 Skorm Posted October 30, 2017 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: April 11 Share Posted October 30, 2017 query_sql("INSERT INTO `event_rewards` ( `account_id`, `event_name`, `id`, `amount`, `value` ) VALUES ( "+.@account_id[.i]+", '"+.@eventname$+"', "+.@prize[.j]+", "+.@pamount[.k]+", 0) "); 1 Quote Link to comment Share on other sites More sharing options...
0 Pandoras Posted October 31, 2017 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 16 Reputation: 3 Joined: 10/01/17 Last Seen: October 9, 2018 Author Share Posted October 31, 2017 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! Quote Link to comment Share on other sites More sharing options...
Question
Pandoras
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 .@count, 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'", .@account_id); set .@eventname$ = "Testing"; setarray .@prize[0],14532,14592,14001,16682,2751,12210; setarray .@pamount[0],3,3,5,1,1,5; for(set .i, 0; .i < getarraysize(.@count); set .i,.i+1) for(set .j, 0; .j < getarraysize(.@prize); set .j,.j+1) for(set .k, 0; .k < getarraysize(.@pamount); set .k,.k+1) set .@reward$, "( .@account_id[.i], '.@eventname$', .@prize[.j], .@pamount[.k], 0)"; query_sql("INSERT INTO `event_rewards` ( `account_id`, `event_name`, `id`, `amount`, `value` ) VALUES '"+ .@reward$ +"' ");
the .@reward$ stands as the value input to the sql insert value.
how can i make .@reward$ 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.