Jump to content
  • 0

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


Question

Posted

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;
}

 

2 answers to this question

Recommended Posts

  • 0
Posted
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;

 

  • 0
Posted
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

 

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