Hey guys I have a table called username, and in my programm i have the possibility to create new users with an username and a password.
But I dont want to have two users with the same username
Im using php and mysql.
How can I handle this?
thx nubu
Hey guys I have a table called username, and in my programm i have the possibility to create new users with an username and a password.
But I dont want to have two users with the same username
Im using php and mysql.
How can I handle this?
thx nubu
add UNIQUE constraint so to enforce distinct values on the column,
ALTER TABLE tableNAme ADD CONSTRAINT tb_unique UNIQUE(username)
 
    
    You can check if the name already exists an ask the user to select a different name;
SELECT COUNT(username) FROM users WHERE userName = '[name to check]'
and add a unique index to the username field
