Jump to content
  • 0

How to display multiple rows of result from SQL query using NPC


gleynn

Question


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  63
  • Reputation:   2
  • Joined:  08/10/12
  • Last Seen:  

Hi,

I have my sample npc script below with SQL query. In database, it has multiple rows of result.
can you please show me how can i make the dispbottom to reflect the first 3 rows of result?
 

image.png.fe6419e9b57ae93a89501183ab29cb21.png

izlude,117,110,6	script	sample	952,{

	input .@item_id;
	query_sql("SELECT char_id, nameid, amount FROM `inventory` HAVING nameid = "+.@item_id+" ORDER BY amount DESC",.@charid,.@nameid,.@amnt);
	dispbottom .@charid+" : "+getitemname(.@nameid)+" "+.@amnt+"pcs";
	end;
}

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

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

On 12/28/2022 at 4:34 AM, gleynn said:

how can i make the dispbottom to reflect the first 3 rows of result?

input .@item_id;
.@size = query_sql("SELECT char_id, nameid, amount FROM `inventory` HAVING nameid = "+.@item_id+" ORDER BY amount DESC LIMIT 3",.@charid,.@nameid,.@amnt);
for (.@i = 0; .@i < .@size; .@i++)
	dispbottom .@charid[.@i]+" : "+getitemname(.@nameid[.@i])+" "+.@amnt[.@i]+"pcs";
end;

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  63
  • Reputation:   2
  • Joined:  08/10/12
  • Last Seen:  

8 minutes ago, gleynn said:

Hi,

I have my sample npc script below with SQL query. In database, it has multiple rows of result.
can you please show me how can i make the dispbottom to reflect the first 3 rows of result?
 

image.png.fe6419e9b57ae93a89501183ab29cb21.png

izlude,117,110,6	script	sample	952,{

	input .@item_id;
	query_sql("SELECT char_id, nameid, amount FROM `inventory` HAVING nameid = "+.@item_id+" ORDER BY amount DESC",.@charid,.@nameid,.@amnt);
	dispbottom .@charid+" : "+getitemname(.@nameid)+" "+.@amnt+"pcs";
	end;
}

 

please ignore my question above, I found this very helpful guide by AnnieRuru

 

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...