Solved

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

Posted on 2002-07-03
6
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Output in PHP throwing alignment of data off issue 12 76
Problem with MySQL query - graph 3 46
Error in sql query statment. 21 70
MySQL 6 48
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 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