
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
MySQL query to replace only the backslashes from folder path?
To replace backslashes with any other special character, use the REPLACE() method. Let us first create a table −
mysql> create table DemoTable827(Path text); Query OK, 0 rows affected (0.69 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable827 values('C\MySQL'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable827 values('D\NewFolder\'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable827 values('E:\myFolder\MyDocument'); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable827;
This will produce the following output −
+------------------------+ | Path | +------------------------+ | C\MySQL | | D\NewFolder\ | | E:\myFolder\MyDocument | +------------------------+ 3 rows in set (0.00 sec)
Following is the query to replace only the backslash from the folder path with another special character −
mysql> update DemoTable827 set Path=REPLACE(Path, '\', '----'); Query OK, 3 rows affected (0.18 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable827;
This will produce the following output −
+------------------------------+ | Path | +------------------------------+ | C----MySQL | | D----NewFolder---- | | E:----myFolder----MyDocument | +------------------------------+ 3 rows in set (0.00 sec)
- Related Articles
- MySQL query to replace only the NULL values from the table?
- MySQL query to replace special characters from column value
- MySQL query to get only the minutes from datetime?
- MySQL query to display only 15 words from the left?
- MySQL query to replace a column value
- Replace only a specific value from a column in MySQL
- MySQL query to get substrings (only the last three characters) from strings?
- How to get the directories (only) from a folder using Java?
- MySQL query to skip the duplicate and select only one from the duplicated values
- MySQL query to replace backslash from a varchar column with preceding backslash string values
- How to remove only the first word from columns values with a MySQL query?
- MySQL query to return the count of only NO values from corresponding column value
- MySQL query to replace part of string before dot
- How to escape backslashes in MySQL with JDBC?
- MySQL query to update only month in date?

Advertisements