tags:

views:

32

answers:

1

I was wondering how can I allow NULL values in the following code below along with keeping WHERE username = '$username'.

here is the mysql code.

"SELECT * 
 FROM users 
 WHERE username  = '$username'
 AND user_id <> '$user_id'"

I'm trying to check for usernames with the same username but I want all users to have a NULL value if they want.

+1  A: 

I believe it's:

SELECT * 
 FROM users 
 WHERE (username ='$username' OR username IS NULL)
 AND user_id <> '$user_id'
Billy ONeal