SA-MP Forums Archive
MYSQL EXIST - 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)
+--- Thread: MYSQL EXIST (/showthread.php?tid=629279)



MYSQL EXIST - itachi - 23.02.2017

need help with if mysql account exist

Help me please


Re: MYSQL EXIST - BiosMarcel - 23.02.2017

do a select and check if the rowcount is 0


Re: MYSQL EXIST - itachi - 23.02.2017

How to please


Re: MYSQL EXIST - Djole1337 - 23.02.2017

It depends on your sql structure. But it should be something like
PHP код:
select `idfrom `accountswhere `name` = 'itachi'
or just
PHP код:
select count(*) from `accountswhere `name` = 'itachi'



Re: MYSQL EXIST - itachi - 23.02.2017

IF NOT ACCOUNT EXIST

Quote:

new query[64+MAX_PLAYER_NAME];
mysql_format(handle, query, sizeof(query), "INSERT INTO `TEST` (nick, hodnost, LOG) VALUES ('%s', 0, 0)", Meno(playerid));
mysql_query(handle, query);

IF ACCOUNTE EXIST

Quote:

new query[64+MAX_PLAYER_NAME];
mysql_format(handle, query, sizeof(query), "UPDATE `ASystem` SET LOG=1 WHERE nick='%s'", Meno(playerid));
mysql_query(handle, query);
mysql_format(handle, query, sizeof(query), "SELECT * FROM `TEST` WHERE nick = '%s'", Meno(playerid));
mysql_query(handle, query);