Have a look at the following SQL statement
select *
from PhoneData
where names = 'yohan'
and nickName = 'yoises'
and mobileNumber1 = 0000000000 or mobileNumber2 = 0000000000
In here, there is a problem. That is this return all the results where the phone number is same. There are 2 rows with the same phone number, so it returns both, by ignoring the name, nick name and all. I assume this is because of the “or” statement. How can I solve this? I need to get details who’s name=yohan and mobileNumber1 or mobileNumber2 = 000000000.
You need some brackets around your OR statements, like this:
Without brackets, it is effectively doing this: