0

Anyone have a clue how I could go about trying to select a certain pattern of numbers with a 1 at the end?

Ex.

SELECT pattern FROM table WHERE pattern REGEXP '1_2+2_2+3_2+4_2&2016-06-09&1';

or

SELECT pattern FROM table WHERE pattern REGEXP '2_1&2016-06-09&1';

using the same number-underscore-number, ampersand, date, ampersand, number; just as long as that number 1 is at the end?

EDIT:

Actually, let me phrase it better. How do I use REGEXP to select an ampersand and the number 1 at the end of a string?

2 Answers 2

3

You don't need regex. Just use LIKE:

LIKE '%&1'

The % makes it not be anchored to the start of the string. LIKE is not regex, but closer to a glob syntax. It may be faster than regex, too.

Sign up to request clarification or add additional context in comments.

Comments

1

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

SELECT column_name
FROM table 
WHERE column_name LIKE '%&1';

Note: You can also use LIKE operator for searching from start not only from end.

Here is an Example.

SELECT column_name
FROM table 
WHERE column_name LIKE '&1%';

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.