List:General Discussion« Previous MessageNext Message »
From:Steve Edberg Date:March 9 2008 6:00am
Subject:Re: Comma's in data?
View as plain text  
At 11:52 PM -0800 3/7/08, J. Todd Slack wrote:
>Hi All,
>
>I have a client that wants to insert data into a VarChar field that contains
>commas. These are property addresses.
>
>Example:
>2966 Moorpark Ave, San Jose, CA, 95128
>
>1 Infinite Loop, Cupertino, CA, 955555
>
>How can I allow this?
>
>Thanks!
>-Jason


I've never had to escape commas; only special characters, eg: '_%. 
MySQL seems to ignore escaping if the following character is not 
special, though:



mysql-5.0.15-log@localhost> create table test (t1 varchar(255));
Query OK, 0 rows affected (0.03 sec)

mysql-5.0.15-log@localhost> insert into test values ('qwert'), 
('qwe,rt'),('qwe\,rt');
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql-5.0.15-log@localhost> select * from test;
+--------+
| t1     |
+--------+
| qwert  |
| qwe,rt |
| qwe,rt |
+--------+
3 rows in set (0.00 sec)



Are you getting an error when you insert a row? If so, what is the 
error? Perhaps you are having a character set issue. This is what 
mine looks like:



mysql-5.0.15-log@localhost> show variables like 'character\_set\_%';
+--------------------------+--------+
| Variable_name            | Value  |
+--------------------------+--------+
| character_set_client     | latin1 |
| character_set_connection | latin1 |
| character_set_database   | latin1 |
| character_set_results    | latin1 |
| character_set_server     | latin1 |
| character_set_system     | utf8   |
+--------------------------+--------+
6 rows in set (0.00 sec)


	steve


-- 
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg                                http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center                            sbedberg@stripped |
| Bioinformatics programming/database/sysadmin             (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+
Thread
Comma's in data?J. Todd Slack8 Mar
  • Re: Comma's in data?obed9 Mar
    • Re: Comma's in data?Kevin Hunter9 Mar
  • Re: Comma's in data?Steve Edberg9 Mar
  • Re: Comma's in data?Martin Gainty9 Mar
  • R: Comma's in data?Nanni Claudio10 Mar