Pandoras Posted October 30, 2017 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 [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? Quote Link to comment Share on other sites More sharing options...
0 Skorm Posted October 30, 2017 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 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...
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