Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-04-2003, 11:51 AM
Kaiyodo
Hill Giant
 
Join Date: Jan 2002
Location: Midlands,UK
Posts: 149
Default Quick MySQL question

I'm trying to write out an SQL text file from my item editor which anyone can source into their database. The problem I've got is that MySQL seems to want me to use two different methods depending on whether the item already exists or not.

If the item doesn't exist I do this ..

INSERT INTO items VALUES (blah blah ..

If it already exists then I do this ..

UPDATE items SET raw_data = '%s' WHERE id = '%d'

Is there a way to combine these two into a 'catch-all' statement? I can write out different entries based on what exists and what doesn't in my database, but that's no use to any one else.

My best guess so far was to write out two lines for each item like this ..

INSERT IGNORE INTO items VALUES (%d,'%s');
UPDATE items SET raw_data = '%s' WHERE id = %d;

The first line will be ignored if the item exists and then the second line will update the existing item. If the item doesn't exist then it gets inserted and then updated again. This looks nasty, anyone know if there's a nicer way?

Thanks.
K.
Reply With Quote
 


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 09: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