Find year range for Mysql REGEXP
P粉545910687
P粉545910687 2024-04-01 14:26:29
0
1
553

I want to separate the content in a table on my movie website based on year intervals, but no matter how hard I try, I can't succeed. Actually, what I want is to list movie files before 1950. I don't know if I made a grammar mistake because I'm a beginner

A Movie 1910
B Movie 1920
C Movie 1930
D Movie 1940
E Movie 1950
F Movie 1970
G Movie 1990


SELECT * FROM streams WHERE type='movie' AND filename REGEXP '/^(190[1-9]\d|194\d)$/';

P粉545910687
P粉545910687

reply all(1)
P粉432930081

The

year is at the end of the filename, not the beginning, so you need to remove the ^ anchor.

There is an extra

0 after 19, so you are matching a 5-digit year starting with 190, not a 4-digit year starting with # Year starting with ##19.

Do not place

/ delimiters around regular expressions in SQL.

SELECT * FROM streams 
WHERE type='movie' 
AND filename REGEXP '19[0-4]\d$';
If you are using MySQL 5.x instead of 8.x, it does not support escape sequences like

\d. Replace it with [0-9] to match numbers.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template