Solved

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

Posted on 2002-07-03
6
403 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 142

Expert Comment

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

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
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now