The forums will be going offline for an extended maintenance period at 1400hrs GMT on 19th June 2025. The number of hours for this downtime is intentionally not advertised due to the nature of these upgrades.
×
- 0
Adding multiple SQL Values using insert
-
Recently Browsing 0 members
- No registered users viewing this page.
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.