Query_sql - Jeybla/rathena GitHub Wiki
title: Query sql permalink: /Query_sql/
Syntax
- query_sql("your MySQL query"{, {, {, ...}}});
- query_logsql("your MySQL query"{, {, {, ...}}});
Description
Executes an SQL query. A 'select' query can fill array variables with up to 128 rows of values, and will return the number of rows (i.e. array size).
Note that query_sql runs on the main database while query_logsql runs on the log database.
Examples
set
.@nb,
query_sql
("SELECT name, fame FROM `char` ORDER BY fame DESC LIMIT 5", .@name$, .@fame);
mes
"Hall Of Fame: TOP5";
for
(
set
.@i,1; .@i <= .@nb; set .@i,.@i+1)
mes
.@i+". "+.@name$[0]+" ("+.@fame[0]+")"; // Will return a person with the biggest fame value.