Question

I have a very long MySQL regex query that I would like to split into multiple lines but I haven't figured out how.
Short version:
select * from table.ips where ipip not regexp '^4\.|^8\.|^12\.|^18\.' order by ipID;

Multi-line non-working version:

select * from table.ips where ipip not regexp '

^4\\.|

^8\\.|

^12\\.|

^18\\.

' order by ipID;    

Thanks in advance.

Was it helpful?

Solution

I don't think there's a free spacing mode in mysql regex...

How about using CONCAT?

select * from table.ips where ipip not regexp concat(
    '^4\\.|',
    '^8\\.|',
    '^12\\.|',
    '^18\\.'
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top