Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1015995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:29:06+00:00 2026-05-16T10:29:06+00:00

We have a huge pattern match in a query (about 12 strings to check).

  • 0

We have a huge pattern match in a query (about 12 strings to check).
Now I have to do this query in MySQL, but it seems that the query from PostgreSQL has not the same syntax.

From PostgreSQL:

SELECT value  
FROM ...  
WHERE ...  
AND `value` !~* '.*(text|text2|text3|text4|text5).*';  

How do I do this in MySQL in a efficient way? I know, that this is probably not efficient at all. What is the most efficient way to do this?

This does the trick, but is probably the worst query possible to do this:

SELECT `value`  
FROM ...  
WHERE ...  

AND NOT (  
   `value` LIKE '%text%'  
OR `value` LIKE '%text2%'  
OR `value` LIKE '%text3%'  
OR `value` LIKE '%text4%'  
OR `value` LIKE '%text5%');  

Is REGEXP the way to go here? Then I’ll have to figure out the corresponding expression.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:29:06+00:00Added an answer on May 16, 2026 at 10:29 am

    Yes, REGEXP or its alternative spelling RLIKE:

    WHERE value NOT RLIKE 'text|text2|text3|text4|text5'
    

    (a regexp match is not anchored to the ends of the string unless you explicitly use ^ and $, so you don’t need the .*(...).*.)

    You should test it to see whether it is actually faster than the version with LIKE. On my test database with four words to find, LIKE was still considerably faster. It also has the advantage of being ANSI standard SQL so you can use it on any database.

    If this is a common query, you should also consider fulltext indexing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this huge RegEx for matching credit cards numbers. But its PCRE. Works
Image that I have a huge database which stores threads and posts from different
I have a JDBC query that will generate a huge ResultSet which cannot be
I have huge amount of data from database, i need to get or store
I have a huge java codebase (more than 10,000 java classes) that makes extensive
I have a huge file of code with many lines like this: Enterprise::TextMessageBox::Show(String::Format(SВъзникнал е
It seems that I have a problem with Linux IO performance. Working with a
I have code that runs on different platforms that seems to get different results.
I have checked in a huge Eclipse project from my desktop computer to the
Hi I need filter out all rows that don't contain symbols from huge necessary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.