I have a problem selecting records with \ in any values.
For example:
SELECT * FROM ADDRESS WHERE STREET = "A\"
will give an error:
If I replace \ with \\ then it works. Eg.
SELECT * FROM ADDRESS WHERE STREET = "A\\"
Is there any setting in MySQL that can overcome this?
Tks
John 12 2517
"zMisc" <yo********@hot mail.com> wrote in message
news:lg******** *********@news-server.bigpond. net.au... If I replace \ with \\ then it works. Eg.
SELECT * FROM ADDRESS WHERE STREET = "A\\"
Is there any setting in MySQL that can overcome this?
What do you mean overcome this? It's a feature of the string literal
syntax, very similar to handling of backslashes within strings in C/C++,
Java, PHP, or Perl.
There seem to be two alternatives, according to http://dev.mysql.com/doc/refman/5.0/...g-syntax.html:
- Process the string with a function that escapes special characters, e.g.
mysql_real_esca pe_string() C API or PHP API functions, or quote() in Perl
DBI. These API functions scan for characters that need the backslash
treatment (like \ or ') and insert the backslashes as needed.
- Use parameterized queries. Prepare a query "SELECT * FROM ADDRESS WHERE
STREET = ?" and then execute the query from your application with a
parameter set to the string "A\". No escaping is necessary when you do this
(except what is required in your application programming language if you
specify the string as a literal).
Regards,
Bill K.
Hi Bill,
As usuall thank you for your response.
I replace \ with \\ before the update and it works.
The problem is I am converting my app that supports MS Access and MS SQL to
now support MySQL so I would prefer not to change all my select to use
parameterized queries.
Access and MS SQL can handle the \ character.
Tks
"Bill Karwin" <bi**@karwin.co m> wrote in message
news:dt******** @enews1.newsguy .com... "zMisc" <yo********@hot mail.com> wrote in message news:lg******** *********@news-server.bigpond. net.au... If I replace \ with \\ then it works. Eg.
SELECT * FROM ADDRESS WHERE STREET = "A\\"
Is there any setting in MySQL that can overcome this?
What do you mean overcome this? It's a feature of the string literal syntax, very similar to handling of backslashes within strings in C/C++, Java, PHP, or Perl.
There seem to be two alternatives, according to http://dev.mysql.com/doc/refman/5.0/...g-syntax.html:
- Process the string with a function that escapes special characters, e.g. mysql_real_esca pe_string() C API or PHP API functions, or quote() in Perl DBI. These API functions scan for characters that need the backslash treatment (like \ or ') and insert the backslashes as needed.
- Use parameterized queries. Prepare a query "SELECT * FROM ADDRESS WHERE STREET = ?" and then execute the query from your application with a parameter set to the string "A\". No escaping is necessary when you do this (except what is required in your application programming language if you specify the string as a literal).
Regards, Bill K.
"zMisc" <yo********@hot mail.com> wrote in message
news:9m******** **********@news-server.bigpond. net.au... Access and MS SQL can handle the \ character.
Okay, I've found an option for you.
MySQL 5.0.3 and later implement a SQL mode called NO_BACKSLASH_ES CAPES.
See http://dev.mysql.com/doc/refman/5.0/...-sql-mode.html for docs on
SQL modes and how to set them at runtime or when the MySQL server starts up.
You might also be interested in the mode MSSQL, to give greater
compatibility with MS SQL Server syntax.
NB: if you use MySQL version prior to 5.0.3, this option is not available.
Regards,
Bill K.
Tks Bill.
"Bill Karwin" <bi**@karwin.co m> wrote in message
news:dt******** @enews2.newsguy .com... "zMisc" <yo********@hot mail.com> wrote in message news:9m******** **********@news-server.bigpond. net.au... Access and MS SQL can handle the \ character.
Okay, I've found an option for you. MySQL 5.0.3 and later implement a SQL mode called NO_BACKSLASH_ES CAPES.
See http://dev.mysql.com/doc/refman/5.0/...-sql-mode.html for docs on SQL modes and how to set them at runtime or when the MySQL server starts up. You might also be interested in the mode MSSQL, to give greater compatibility with MS SQL Server syntax.
NB: if you use MySQL version prior to 5.0.3, this option is not available.
Regards, Bill K.
Hi Bill,
Where can I find the MySQL version? I look at MySQL.exe and there's no
version property.
Tks
"Bill Karwin" <bi**@karwin.co m> wrote in message
news:dt******** @enews2.newsguy .com... "zMisc" <yo********@hot mail.com> wrote in message news:9m******** **********@news-server.bigpond. net.au... Access and MS SQL can handle the \ character.
Okay, I've found an option for you. MySQL 5.0.3 and later implement a SQL mode called NO_BACKSLASH_ES CAPES.
See http://dev.mysql.com/doc/refman/5.0/...-sql-mode.html for docs on SQL modes and how to set them at runtime or when the MySQL server starts up. You might also be interested in the mode MSSQL, to give greater compatibility with MS SQL Server syntax.
NB: if you use MySQL version prior to 5.0.3, this option is not available.
Regards, Bill K.
"zMisc" <yo********@hot mail.com> wrote in message
news:va******** **********@news-server.bigpond. net.au... Where can I find the MySQL version? I look at MySQL.exe and there's no version property.
To get the MySQL server version (which is more relevant in this case),
connect to the MySQL server and issue a statement:
SHOW VARIABLES LIKE 'version';
The get the MySQL client version, you can run the command
"mysql.exe --version".
I make the distinction because the version of the client and the version of
the server are not necessarily the same, especially if you're using the
client to connect to a MySQL server instance running on another machine.
Regards,
Bill K.
Hi Bill,
Tks.
I've tried setting:
set sql_mode = 'NO_BACKSLASH_E SCAPES'
then try this:
SELECT * FROM `TEST` WHERE `ADDRESS` = '1\10'
and get a syntax error. But:
SELECT * FROM `TEST` WHERE `ADDRESS` = '1\\10'
still works. It looks like set sql_mode = 'NO_BACKSLASH_E SCAPES' makes no
difference.
"Bill Karwin" <bi**@karwin.co m> wrote in message
news:dt******** *@enews1.newsgu y.com... "zMisc" <yo********@hot mail.com> wrote in message news:va******** **********@news-server.bigpond. net.au... Where can I find the MySQL version? I look at MySQL.exe and there's no version property.
To get the MySQL server version (which is more relevant in this case), connect to the MySQL server and issue a statement: SHOW VARIABLES LIKE 'version';
The get the MySQL client version, you can run the command "mysql.exe --version".
I make the distinction because the version of the client and the version of the server are not necessarily the same, especially if you're using the client to connect to a MySQL server instance running on another machine.
Regards, Bill K.
"zMisc" <yo********@hot mail.com> wrote in message
news:Of******** **********@news-server.bigpond. net.au... It looks like set sql_mode = 'NO_BACKSLASH_E SCAPES' makes no difference.
I tried that too, and like you said, it didn't seem to have any effect.
I got it to work with:
set global sql_mode='NO_BA CKSLASH_ESCAPES ';
select 'foo\\bar'';
Gives: foo\\bar whereas that query gave foo\bar before.
Regards,
Bill K.
zMisc wrote: I have a problem selecting records with \ in any values.
For example:
SELECT * FROM ADDRESS WHERE STREET = "A\"
will give an error:
If I replace \ with \\ then it works. Eg.
SELECT * FROM ADDRESS WHERE STREET = "A\\"
Is there any setting in MySQL that can overcome this?
Tks John
As an ANSI standard the default should be NO_BACKSLASH_ES CAPES. Anything
contained with the quotes 'xx\x\x\x' should be treated as data and NEVER
interpreted to be anything else. So, whoever the orginal designers were spent
way too much time working on **IX\Windows crap OS's.
IMHO Another flaw in MySQL.
Data is Data and should never to be treated the same as you would a variable in
an OS-level scripting language.
--
Michael Austin.
DBA Consultant
Donations welcomed. Http://www.firstdbasource.com/donations.html
:) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Darren Smith |
last post by:
I am having a great deal of difficulty accessing individual fields
generated from a Sql Server 7 view.
When I specify the actual field name, I get the error:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
The column prefix
'inventory_hardware' does not match with a table name or alias name
used in the query.
|
by: Dave |
last post by:
Hi
I'm making a 3D Engine which consists of the class C3DEngine. Part of this
engine is a file loader, a class called CMeshLoader.
I have made an instance of CMeshLoader in C3DEngine, ie composition.
Unfortunately, CMeshLoader sometimes needs to refer
to private members of C3DEngine. Inheritance, friends, and composition are
all swirling around in my head at the moment. I know that
inheritance is not the solution. Can someone please...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen. It is
almost like it is trying to implement it's own COM interfaces...
below is the header, and a link to the dll+code:
Zip file with header, example, and DLL:...
|
by: Scott M. Lyon |
last post by:
I've just discovered a bug in some code I wrote a little while ago, and I
need you guys' help to fix it.
My program imports data from a standard Excel Spreadsheet (just with
specific column headers). I used ODBC in my VB.NET program to read that
spreadsheet into a dataset, to make it easy to manipulate. The code I use to
read it is as the bottom of this posting.
|
by: E.T. Grey |
last post by:
Hi,
I have an interesting problem. I have a (LARGE) set of historical data
that I want to keep on a central server, as several separate files. I
want a client process to be able to request the data in a specific file
by specifying the file name, start date/time and end date/time.
The files are in binary format, to conserve space on the server (as well
as to increase processing time). The data in each file can be quite
large, covering...
| |
by: Martin Jørgensen |
last post by:
Hi,
I'm relatively new with C-programming and even though I've read about
pointers and arrays many times, it's a topic that is a little confusing
to me - at least at this moment:
----
1) What's the difference between these 3 statements:
(i) memcpy(&b, &KoefD, n); // this works somewhere in my code
|
by: weidongtom |
last post by:
Hi,
I tried to implement the Universal Machine as described in
http://www.boundvariable.org/task.shtml, and I managed to get one
implemented (After looking at what other's have done.) But when I use
to run a UM program, I kept on getting error messages. I have used
someone else's implementation and it runs fine. I have compared my
code with other's and I still can't figure it out what's wrong with
mine. So please help me out, after 3...
|
by: mitrofun63 |
last post by:
Hello.
On my production site i have DB2 9.1.2 database configured for
archiving logs and making backup through
TSM Data Protection for DB2 UDB
The LOGARCHMETH1 parameter is set to LOGARCHMETH1=VENDOR:/usr/tivoli/
tsm/tdp_r3/db264/libtdpdb264.a
I make an online backup with include logs to servers local disk and
then tranfer backup image to my test box for backup validate.
|
by: djsuson |
last post by:
I'm trying to set up an inheritance tree that also uses templates. This is an attempt to simplify some previous code that was filled with redundancies. I'm working with g++ 3.4.6. The code is split over four files: two headers and two implamentation files, but uses the include trick mentioned on another thread to connect the header and implamentation files together. The base class header is
#ifndef _BASEDATA_H_
#define _BASEDATA_H_
...
|
by: Meendar |
last post by:
Hi,
Below is my code snippet having only one form,
<form>
<input type ="radio" name="action" value="xyz" checked>xyz
<input type ="radio" name="action" value="zyx">zyx
<input type ="radio" name="action" value="yxz">yxz
</form>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |