Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Is it possible to avoid the special meaning on '\' [backslash] in a MySql Query

Posted on 2002-07-03
6
Medium Priority
?
421 Views
Last Modified: 2008-02-20
I have a big problem!
I am storing the [windows] path of a file in a MySql
Table.
When I am Searching for a particular path
Example:
--------
Select FILENAME from MyTable
Where
Path='C:\WINDOWS\DESKTOP\myfile.txt';
[BUT \ has a special meaning to mysql] so
I have to give Path='C:\\WINDOWS\\DESKTOP\\myfile.txt';
Is it Possible to avoid the specail meaning of '\' in
a MySql Query.This is creating a lot of problems.....
For Example I have a Field EngLish Title which has a value
MANAGER/DIRECTOR.
I Cannot directly search for the string 'MANAGER/DIRECTOR'.
I have to convert / TO // ..............
I there any way to avoid this .....

0
Comment
Question by:soft_ware
6 Comments
 
LVL 2

Expert Comment

by:vasan_sr
ID: 7126418
u have to append '/' to the existing path and to store...can u pls explain why r u storing the path..?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7126430
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7126434
seems the page has connection problems :-(

What you can read is this:
To specify a different escape character, use the ESCAPE clause:
mysql> SELECT 'David_' LIKE 'David|_' ESCAPE '|';

CHeers
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 5

Expert Comment

by:kelfink
ID: 7128174
There's no way to turn off the \ escape symbol in literals...

I think a good example of what you're talking about is, trying to store:

insert into myTable values ( 'run', 'c:\windows');
which results in
mysql> select * from myTable;
+----------+-----------+
| FILENAME | path      |
+----------+-----------+
| run      | c:windows |
+----------+-----------+
1 row in set (0.00 sec)
Worse, if your string ends with the backslash, mySQL escapes the ' symbol:

insert into myTable values ( 'run', 'c:\windows\');
continues until you add a "'); " to truly terminate it.

I've been bit by this enough that I generally just use binding through the JDBC interface, which does not cause the same problem.




0
 

Expert Comment

by:modulo
ID: 7802847
Dear soft_ware,

These are all your outstanding Q's:
http://www.experts-exchange.com/Databases/Mysql/Q_20319017.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20310655.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20310709.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20440256.html
http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20283355.html
None of them is closed and many lack response comments from you.

Please finalize them !

Expert(s),

Please post a closure recommandation.
When no comment has been added within seven days I'll finalize this Q with a:

- PAQ and no refund

Thanks !

modulo

Community Support Moderator
Experts Exchange
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 7852962
PAQ and no refund

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question