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)$/';
The
year is at the end of the filename, not the beginning, so you need to remove the
There is an extra^
anchor.0
Do not placeafter
19
, so you are matching a 5-digit year starting with190
, not a 4-digit year starting with # Year starting with ##19.
/
If you are using MySQL 5.x instead of 8.x, it does not support escape sequences likedelimiters around regular expressions in SQL.
\d
. Replace it with
[0-9]to match numbers.