Solved

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

Posted on 2002-07-03
6
410 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikipedia.org/wiki/PHP  Very powerful.  But a…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

803 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