

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we match the values having backslashes, like ‘a\b’, from MySQL column?
With the help of an RLIKE operator, we can perform such kind of matching. The only concept is about to use a number of backslashes in MySQL query. The example below will make it clearer −
We have the following table having values such as ‘a\b’ and ‘a\\b’.
mysql> select * from backslashes; +------+-------+ | Id | Value | +------+-------+ | 1 | 200 | | 2 | 300 | | 4 | a\\b | | 3 | a\b | +------+-------+ 4 rows in set (0.10 sec)
Now suppose if we want to match the value ‘a\\b’ then we need to write eight backslashes. It is because the second backslash is not escaped by the first so to compare two liters we need to double the backslash but as we are querying a table for such string from the MySQL string then this doubling happens twice-once in the client and once in the database. Hence we need to use four times backslashes as done in the queries below −
mysql> Select * from backslashes where value RLIKE 'a\\\\\\\\b'; +------+-------+ | Id | Value | +------+-------+ | 4 | a\\b | +------+-------+ 1 row in set (0.00 sec) mysql> Select * from backslashes where value RLIKE 'a\\\\b'; +------+-------+ | Id | Value | +------+-------+ | 3 | a\b | +------+-------+ 1 row in set (0.01 sec)
- Related Questions & Answers
- How can we match the values having backslashes, like ‘a\\b’, from MySQL column?
- How can create a table having the name like a^b along with same column name? name?
- How can we retrieve the output having decimal values of a column in a specified format?
- How can we remove a column from MySQL table?
- How can we update MySQL table after removing a particular string from the values of column?
- MySQL query to match any of the two strings from column values
- MySQL ENUM column match for quoted values
- Match column values on the basis of the other two column values in MySQL
- Can we insert values without mentioning the column name in MySQL?
- Can we skip a column name while inserting values in MySQL?
- What MySQL returns when we use DISTINCT clause with the column having multiple NULL values?
- How can we simulate the MySQL INTERSECT query having WHERE clause?
- How can we update MySQL table after padding a string with the values of the column?
- How can we extract a substring from the value of a column in MySQL table?
- How MySQL SUM() function evaluates if the column having NULL values too?
- How do I select data from one table only where column values from that table match the column values of another table in MySQL?
Advertisements