views:

50

answers:

3

Hi! 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
                 ";              
`
A: 

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.

Brendan Long
+1  A: 

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.

TehShrike
its actually a varchar with a string, but i'll change it to a boolean and try that
Pete Herbert Penito
Oh hey, don't go doing that on a whim - nothing wrong with storing string values.What are some sample values from the table?
TehShrike
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,
Pete Herbert Penito
interestingly when i run the same query through navicat it worked properly
Pete Herbert Penito
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 "; `
Pete Herbert Penito
A: 

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

is correct

Pete Herbert Penito