Inserting Values with ticks in a SQL-Field

Questions regarding syntax

Inserting Values with ticks in a SQL-Field

Postby PMan » Sat Jan 08, 2011 12:06 pm

Hi,

how can I insert and update SQL-Field with values with a tick like "Côte d'Ivoire" or " don't"?

Using

.... Set Country = 'Côte d'Ivoire' , ...

don't work because of the three ticks in the statament.

/PMan
PMan
 
Posts: 145
Joined: Sat Jul 03, 2010 12:31 pm
Location: Switzerland

Re: Inserting Values with ticks in a SQL-Field

Postby Henning » Sat Jan 08, 2011 12:31 pm

In MySQL that is \' (backslash tick).

There are several ways to include quote characters within a string:

A “'” inside a string quoted with “'” may be written as “''”.

A “"” inside a string quoted with “"” may be written as “""”.

Precede the quote character by an escape character (“\”).

A “'” inside a string quoted with “"” needs no special treatment and need not be doubled or escaped. In the same way, “"” inside a string quoted with “'” needs no special treatment.


/Henning
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden


Return to Coding Questions

cron