Answer the question
In order to leave comments, you need to log in
How to compose query in mysql to find range between text?
Help me write a request for this field
`cca` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|cca |
|-------|
|360-530|
|360-600|
|360-530|
|360-530|
|360-530|
Answer the question
In order to leave comments, you need to log in
You can use a stored function - something like this:
drop function if exists checkRange;
DELIMITER //
CREATE FUNCTION checkRange(strRange varchar, from int, to int) RETURNS bool
DETERMINISTIC
BEGIN
DECLARE left INT;
DECLARE right INT;
SELECT strRange REGEXP ... INTO left
SET result = ...;
RETURN (result);
END//
DELIMITER ;
....
SELCET * FROM table WHERE checkRange(randeColumn, 360, 530)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question