Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::Windows Servers

Support::Windows Servers Support forum for Windows EQEMu users.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2011, 04:29 PM
Kingmen30264
Hill Giant
 
Join Date: Sep 2006
Posts: 112
Default SQL Commands..........?

I was just wondering if someone could tell me of an easier way of making a command that will insert multiple values at one time (one line) instead of multiple lines.

Here is an example of what I am asking for:

Code:
insert into `tablename`(values) values (number, >= ### and <= ###);
Here is something that I did before and took me a GOOD minute:

Code:

INSERT INTO `goallists` (`listid`, `entry`) VALUES
(700, 219000),
(700, 219001),
(700, 219002),
(700, 219003),
(700, 219004),
(700, 219005),
(700, 219006),
(700, 219007),
(700, 219008),
(700, 219009),
(700, 219010),
(700, 219011),
(700, 219012),
(700, 219013),
(700, 219014),
(700, 219015),
(700, 219016),
(700, 219017),
(700, 219018),
(700, 219019),
(700, 219020),
(700, 219021),
(700, 219022),
(700, 219023),
(700, 219024),
(700, 219025),
(700, 219026),
(700, 219027),
(700, 219028),
(700, 219029),
(700, 219030),
(700, 219031),
(700, 219032),
(700, 219033),
(700, 219034),
(700, 219035),
(700, 219036),
(700, 219037),
(700, 219038),
(700, 219039),
(700, 219040),
(700, 219041),
(700, 219042),
(700, 219043),
(700, 219044),
(700, 219045),
(700, 219046),
(700, 219047),
(700, 219048),
(700, 219049),
(700, 219050),
(700, 219051),
(700, 219052),
(700, 219053);
I am not wanting to do something like that again.... specially since I have about 15 other zones that I am trying to do this to, and I don't really have a lot of time atm (school/college) to work with this.

Any and all help is greatly appreciated. (Yes, I have been searching on an answer on my own [when I can].)

Thanks,

Kingmen
Reply With Quote
  #2  
Old 08-28-2011, 05:48 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

Assuming your values are all consecutive. then this seems to work:
Code:
set @listid = 700;
set @start = 219000;
set @end = 219053;
DELETE from goallists where listid = @listid;
DROP PROCEDURE IF EXISTS myProc;
delimiter $$
CREATE PROCEDURE myProc()
DETERMINISTIC
BEGIN
   DECLARE counter INT DEFAULT @start;

   simple_loop: LOOP
     INSERT INTO `goallists` (`listid`, `entry`) VALUES (@listid, counter);
     SET counter=counter+1;
     IF counter>@end THEN
        LEAVE simple_loop;
     END IF;
   END LOOP simple_loop;
   SELECT * from goallists where listid = @listid;
END$$
delimiter ;
call myProc();
Just change the listid, start and end values at the top of the code to what you want.

PS: I had to google for how to do this (I'm not an SQL expert either ), code copied from here: http://www.java2s.com/Code/SQL/Proce...SimpleLOOP.htm

Last edited by Derision; 08-28-2011 at 06:17 PM.. Reason: Moved INSERT before increment / changed end condition
Reply With Quote
  #3  
Old 08-28-2011, 07:04 PM
Kingmen30264
Hill Giant
 
Join Date: Sep 2006
Posts: 112
Default

VERY Nice. Thank you so much Derision... This worked like a charm
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 02:48 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3