Jump to content
  • 0

how to do SQL Querying


Question

Posted

Just wanna ask how to do SQL Querying. to be specific How to make an SQL Query to get a character's CharID from SQLdb?

help will be very much appreciated. /ok

6 answers to this question

Recommended Posts

Posted

well you can refer to this

http://dev.mysql.com/doc/refman/5.0/en/select.html

Example:

set @nb, query_sql("select name,fame from `char` ORDER BY fame DESC LIMIT 5", @name$, @fame);
mes "Hall Of Fame: TOP5";
mes "1."+@name$[0]+"("+@fame[0]+")"; // Will return a person with the biggest fame value.
mes "2."+@name$[1]+"("+@fame[1]+")";
mes "3."+@name$[2]+"("+@fame[2]+")";
mes "4."+@name$[3]+"("+@fame[3]+")";
mes "5."+@name$[4]+"("+@fame[4]+")";

  • Upvote 1
Posted

I see. looking at script.c for query_sql, does it also allow you to write data into it?

like

UPDATE `ragnarok`.`char` SET `name`='Jezznar' WHERE `char_id`='150002';

will this be possible?

Posted

alright. and by the way, I was wondering why this was moved in the scripting section? @_@

well, thanks anyway I was supposed to write a separate one for scripting since I also need to know

how to do it in the source side.

and thanks for the answers :)

Posted

i though you are just requesting this to work in a NPC/Script so i move this to script support..

if you want to do it in source part..

you can refer to some example , ( picked randomly inside the src files )

//Update DB
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
 Sql_ShowDebug(sql_handle);

  • Upvote 1
Posted

this really helps. my freakin' VS2010 kinda crashes 9/10 of the time so I had to do the last resort~ and that's ask in the support section. :D

anyway big thanks!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...