3

I'm trying to build a query which matches the rows following these rules :

  • my rows contents ids like 'MATCH_1', 'MATCH_2', 'MATCH_4'...
  • I want to match the rows which id is between 2 boundaries: SELECT id FROM table WHERE id LIKE "MATCH_%", % must be between 2 and 5 for example. The result must be : 'MATCH_2', 'MATCH_4', 'MATCH_5'

Is it possible to do so ?

Thanks

1
  • And I suppose that MATCH_10 is not between MATCH_1 and MATCH_2, is it? Commented Mar 5, 2013 at 9:59

1 Answer 1

7

you mean this?

 SELECT * 
   FROM table
  WHERE row 
BETWEEN 'MATCH_2' AND 'MATCH_5';

or converted to int

  SELECT *
    FROM table
   WHERE CAST(SUBSTRING(row FROM 7) AS UNSIGNED)
 BETWEEN 2 AND 5;
Sign up to request clarification or add additional context in comments.

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.