1

I have a question, I would like to make a query in mysqli.

I want to do this

 $sql = $db->query("SELECT * FROM padges WHERE enable ='1' AND enable='0'");

But it is not working. How do I solve this ?

2
  • You need to provide more detail. We are surely not a bunch of people looking through a crystal ball. Commented Oct 7, 2015 at 14:30
  • "But it is not working". Please elaborate. Commented Oct 7, 2015 at 14:35

1 Answer 1

1

An enable ='1' AND enable='0' condition won't return any rows. Because database does search not the way you think it is. It will pick rows one by one, and test each against this condition. And obviously find no rows, as there couldn't be a row that's enabled and disabled at the same time. Instead you have to find rows that are either enabled or disabled:

SELECT * FROM padges WHERE enable ='1' OR enable='0'

Or, if 0 and 1 are the only values, you can omit WHERE clause at all

SELECT * FROM padges
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.