0

This query that I have is returning therapists whose 'therapistTable.activated' is equal to false as well as those set to true! so it's basically selecting all of the db, any advice would be appreciated!

`           $query = "SELECT
                 therapistTable.*
                 FROM
                 therapistTable
                 WHERE
                 therapistTable.activated = 'true'
                 ORDER BY 
                 therapistTable.distance
                 ";              
`
3
  • 1
    Pete: In your question, please provide the output of the following SHOW CREATE TABLE therapistTable Commented Mar 19, 2010 at 23:36
  • im sorry but theres some sensitive info in it Commented Mar 19, 2010 at 23:53
  • show create table, wont show any data. Commented Mar 20, 2010 at 0:08

3 Answers 3

1

What is the column type of the column activated, and what are some sample values from the table?

Is it perhaps a BOOL, or some other integer value? 'true' is a string - TRUE is an integer.

If therapistTable.activated is a BOOL, you will want to compare it to TRUE instead of a string.

Sign up to request clarification or add additional context in comments.

5 Comments

its actually a varchar with a string, but i'll change it to a boolean and try that
Oh hey, don't go doing that on a whim - nothing wrong with storing string values. What are some sample values from the table?
k it didn't work, i turned it back to a varchar i use navicat to set the value of therapistTable.activated to true or false no quotes or anything just that,
interestingly when i run the same query through navicat it worked properly
i got it i apologize turns out that wasnt the query being sent, the query runs perfectly well like ` $query = "SELECT therapistTable.* FROM therapistTable WHERE therapistTable.activated = 'true' ORDER BY therapistTable.distance "; `
0

If you're using a boolean type, you should be using TRUE and not'true'. I don't know how that would cause your problem though..

Just to explain: TRUE is an integer (equal to 1), but 'true' is a string.

Comments

0

$query = "SELECT therapistTable.* FROM therapistTable WHERE therapistTable.activated = 'true' ORDER BY therapistTable.distance ";

is correct

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.