SA-MP Forums Archive
Mysql question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Mysql question (/showthread.php?tid=221929)



Mysql question - iJumbo - 06.02.2011

i have a simple mysql question

i have a table with one row called Name

like this

Name

[ISS]jumbo
blabla
blabla2
LOL
omg
xD


with all names and i want to get one name in random! how i can do it ?


Re: Mysql question - iJumbo - 06.02.2011

please <.<


Re: Mysql question - Calgon - 06.02.2011

For your MySQL query:
Код:
SELECT Name FROM table ORDER BY RAND() LIMIT 1
The query selects the name (you might want to change 'Name' to your field name for player names) and from table (you'll need to change table to the table where you keep your users) and it orders randomly and limits the query to only return 1 result.


Re: Mysql question - iJumbo - 06.02.2011

pawn Код:
format(query,sizeof(query),"SELECT NomePlayer FROM players ORDER BY Rand() LIMIT 2");
        mysql_query(query);
        mysql_store_result();
        while(mysql_fetch_row_format(Data,"|"))
        {
            sscanf(Data, "p|s", Test[0]);
            printf("Nome %s",Test[0]);
        }
        mysql_free_result();
this show me 2 names in random right?