开发者

How to use Boolean logic in a mySQL SELECT query

开发者 https://www.devze.com 2023-01-18 04:37 出处:网络
How can I check if email = \'$e\' or username = \'$e\' inside my MySQL query. Here is my MySQL query so far.

How can I check if email = '$e' or username = '$e' inside my MySQL query.

Here is my MySQL query so far.

"SELECT user_id FROM users WHERE (email = '$e' AND pass=SHA1('$p'))"  开发者_如何转开发      


If you want to modify you existing query so that it works even if $e matches username, you can do:

SELECT user_id 
FROM users 
WHERE (email = '$e' OR username = '$e') AND pass=SHA1('$p')
0

精彩评论

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