Jump to content
  • 0

how to do SQL Querying


Ninja

Question


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

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

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

all SQL related stuff is working....

so far i didnt see any of it didnt work....

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

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!

Link to comment
Share on other sites

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.

×
×
  • Create New...