Solved

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

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mysql sync between 3-4 mysql db 4 45
Sql query on a varchar that is numeric. 8 47
updating the date data 12 39
Create a MySQL table as easily as possible 6 60
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
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…

713 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