Select specific data MYSQL
#4

Well, then it's quite straightforward:
Код:
SELECT fieldname FROM yourtable WHERE somecondition = somevalue LIMIT
I can't recommend mysql_format as %e and few other arguments are broken before R9. Also bear in mind that I never wrote any unthreaded queries (and if you can, please upgrade to them before your server lags to death).
pawn Код:
new
    id = 666,
    query[64];

format(query, sizeof query, "SELECT fieldname FROM yourtable WHERE id = %d LIMIT 0, 1", id);

mysql_query(query);

mysql_store_result();
if(mysql_errno() != 0 || mysql_num_rows() == 0) {
    printf("[Err]: Something wrong when executing query with parameter %d", id);
} else {
    new
        fieldvalue = mysql_fetch_int();

    printf("Fetched value %d for %d!", fieldvalue, id);
}
mysql_free_result();
Of course change "fieldname" and "tablename", and change your where clause (and if your string gets longer watch out for size of query variable - it's only 64 at the moment)
Reply


Messages In This Thread
Select specific data MYSQL - by Giannidw - 21.08.2014, 12:15
Re: Select specific data MYSQL - by Misiur - 21.08.2014, 14:43
Re: Select specific data MYSQL - by Giannidw - 21.08.2014, 15:02
Re: Select specific data MYSQL - by Misiur - 21.08.2014, 15:14

Forum Jump:


Users browsing this thread: 1 Guest(s)