WIth most databases you could jsut try to SELECT it first, then INSERT if you don't find it. You should put both queries in a TRANSACTION block. But that doesn't work with mysql because it doesn't support transactions.
Another good alternative is to put a unique index on the column(s) that identify the user and try the INSERT. If it fails (because of a duplicate key) you can handle the error.