Possible Duplicate:
Best way to avoid duplicate entry into mysql database
this is my query to add the user and denying them if there already exists an user with the same name in the user table:
insert into user values(?, ?, ?, ? ) select * from user
where NOT EXISTS(select * from user where user.username = ?);