I have a database structured as follows:
users
userid (Primary Key)
username
group
Basically you can do it like this:
IF NOT EXISTS (SELECT * FROM USER WHERE username = @username)
INSERT INTO users (username) VALUES (@username)
But seriously, how you're going to know if user visited your website for the first time? You have to insert records in table user, when somebody register on your website, not login.