开发者

How can I allow NULL values in MySQL

开发者 https://www.devze.com 2022-12-27 15:32 出处:网络
I was wondering how can I allow NULL values in the following code below along with keeping WHERE usern开发者_JS百科ame= \'$username\'.

I was wondering how can I allow NULL values in the following code below along with keeping WHERE usern开发者_JS百科ame = '$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.


I believe it's:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号