Regarding the integrity of the data, it would be more interesting to change the type of the column, to decimal, if you have difficulty doing so, ask a question.
Now if you can’t change the column type, we’ll have to use the function cast, of which changes the data type of the column.
Let’s just have the table, which already has the data of your question:
CREATE TABLE IF NOT EXISTS tabela (
coluna varchar(200) NOT NULL
) DEFAULT CHARSET=utf8;
Doing the consultation:
select coluna
from (SELECT CAST(t.coluna AS DECIMAL(5, 2)) coluna FROM tabela t) a
where a.coluna >= 2
AND a.coluna <= 4
We’d be converting the column of VARCHAR, for DECIMAL(5,2). I put in a sub-colony so I wouldn’t be doing the CAST 2x, but I recommend using the between.
Following example:
http://sqlfiddle.com/#! 9/d07d15/1
But inside the WHERE that would look like?
– caiocafardo
I adjusted the answer :)))))))
– Filipe L. Constante
You can use between instead of operators >= <= :) Facilitates writing.. :)
– Filipe L. Constante
Give feedback if your question has been resolved and mark the answer as correct if positive. : ) This will help other users to resolve the question if it is similar to yours.
– Filipe L. Constante