views:

78

answers:

3

How to write this meaning in a MySQL query?

where ((location/'$location'<2) and (location/'$location'>=1))
A: 
where location/'$location' between 1 and 2

Edit: Since it should only match those that are precisely 2, then this should work:

where location div '$location' = 2
Tor Valamo
The range is [1,2) location and $location are integers.
Steven
So basically range is 2. Period. Ergo "where location/'$location' == 2" ?
Tor Valamo
You can edit your answer to add content - the edit link is to the right of the voting, between link and flag.
OMG Ponies
fwiw, `==` is not an operator in SQL.
Bill Karwin
haha.. sorry... edited :p
Tor Valamo
A: 

If you want floating-point division, that should be fine, but if you want integer division:

WHERE location DIV '$location' IN (1, 2)
jboxer
The range is [1,2)
Steven
A: 

I would have to know a bit more about your database but are you trying to select something such as:

select location from -- some table 
where ((location/'$location'<2) and (location/'$location'>=0))
tuckster