.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

How to use "AND" and "OR" operator together?

Posted By: ASPEvil     Posted Date: November 09, 2010    Points:2   Category :Sql Server

I did face a problem while I was trying to use "AND" and "OR" operator together.

My requirement is : There are three fields in a table namely "email","password","phone" and the table name is "members". There is a LogIn page where the user are being asked to enter their emailid or phone number as the login id and password as their password and I am checking these data with the table "members", which is having these data.

I wrote the query as below:-
select * from members where email='aaa@aaa.com' or phone='123456' and [password]='aaaaaa'

The problem is that, it is not at all checking the value of the password as whether it is right or wrong.

Please let me know how to resolve this issue.

Author: ASPEvil             
Posted Date: November 09, 2010     Points: 5   

I got the solution. I was actually missing the braces, so the right query will be as follow:-

select * from members where [password]='aaaaaa' and (email='aaa@aaa.com' or phone='123456')

Author: sriram             
Posted Date: October 27, 2011     Points: 20   

select * from members where username='aaaa' and password='bbbbb' or phone='123555'

Hope this will help

let me know any Queries...



Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend