View Full Version : sqlite count()

15/04/2017, 02:02 PM
Hi, I'm creating a namechange dialog and I don't want the player to be able to change his name if it's used already, but it's not working for some reason. This is the part which is not working:
new query[100], DBResult:result;

format(query, sizeof(query), "SELECT COUNT(*) FROM accounts WHERE Name = 'q' COLLATE NOCASE", inputtext);
result = db_query(database, query);

if (db_get_field_int(result, 0)) ShowPlayerDialog(playerid, DIALOG_CHANGE_NAME, DIALOG_STYLE_INPUT, "Change Name", "That name is already in use by someone else.\nPlease type your new desired name below:", "Change", "Cancel");
so basically it returns 0 rows while there is actually a row with the name I'm trying to set for myself. What's the problem?

EDIT: lol i'm stupid it has to be %q

15/04/2017, 03:49 PM
sorry, didn't saw the edit

15/04/2017, 08:02 PM
Not sure if it works but did you try count(id)?

So if it finds any ID with the name that the player entered it means that the name is used :?