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 8755127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:47:09+00:00 2026-06-13T13:47:09+00:00

Consider the following table : mysql> select * from test; +———+ | col |

  • 0

Consider the following table :

mysql> select * from test;
+---------+
| col     |
+---------+
| ^test$  |
| tes$()t |
| X$%[    |
| test$   |
| ^test   |
| test    |
| [       |
+---------+
7 rows in set (0.04 sec)

It contains valid and invalid patterns.

If I do :

mysql> select * from test where 'test' regexp col;
+--------+
| col    |
+--------+
| ^test$ |
| test$  |
| ^test  |
| test   |
+--------+
4 rows in set (0.04 sec)

I get all rows with a pattern matching ‘test’, and all other rows (including invalid patterns) are just ignored.

Now, if I do an invalid request directly, I get a pattern syntax error :

mysql> select * from test where 'test' regexp '[';
ERROR 1139 (42000): Got error 'brackets ([ ]) not balanced' from regexp

Is there a way (without another table) to force MySQL to ignore those errors (will give an empty result for example) ?

  • 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-06-13T13:47:10+00:00Added an answer on June 13, 2026 at 1:47 pm

    Okey I found a working solution, that’s tricky but that work :

    SELECT * FROM test WHERE 'test' REGEXP RIGHT(CONCAT(col, '['), LENGTH('['));
    

    Replace ‘[‘ by your regexp pattern. May be useful if you allow your customers to use regexps.

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

Sidebar

Related Questions

Consider the following table: mysql> select * from phone_numbers; +-------------+------+-----------+ | number | type
Consider the following table: mysql> select * from vCountryStatus; +-------------+------------+------+---------+--------+-----------------+ | CountryName | CountryISO
Consider following MySQL table: CREATE TABLE `log` ( `what` enum('add', 'edit', 'remove') CHARACTER SET
Consider a MySQL table with a datetime field. I would like to select the
Consider the following database tables: Table messages with 13,000,000 rows (one row per message).
Consider the following table: <table> <thead> <tr> <th scope=col /> <th scope=col>A</th> <th scope=col>B</th>
MySQL server version 5.0.45. Consider the following: ( SELECT CASE WHEN t.group_id = 12
Consider the following two queries: select a.*, c.* from account a join customer c
Please consider the table bd.nn that contains roughly 19 million records: > SELECT n,
Consider the following MySQL tables: MORTALITY (contains which raisers have deceased piglets) raiserID |

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.