2012-01-26 13 views
5

私はウェブサイトから送信された情報のデータベースを持っています。メインカラムのデータは、マークダウンを使用して入力し、このようになりますテキストがたくさん含まれていました:phpMyAdminでエスケープ文字を使用したREPLACEの使用

Walgreens (www.walgreens.com) is the nation\\\'s largest drugstore chain. 

我々は異なるWYSIWYGエディタへの切り替え、およびデータをクリーンアップする必要がありますが。私は、phpMyAdminの中でこれをやってみました:

UPDATE sc_answer 
SET answer_text = REPLACE (answer_text, '\\\', '') 
WHERE sc_answer_id = 24806 

が、私はエラーを取得:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''\\\', '') WHERE sc_answer_id = 24806' at line 3 

は、誰も私を助けることはできますか?これを機能させるには何が必要ですか?

答えて

4

テキストフィールドにバックスラッシュ\がある場合は、SQLで2つのバックスラッシュを使用します。たとえば、あなたのテーブルは次のように見える場合:

mysql> select * from foo; 
+----+---------------------------------------------------------------------------+ 
| id | bar                  | 
+----+---------------------------------------------------------------------------+ 
| 1 | Walgreens (www.walgreens.com) is the nation\\\'s largest drugstore chain. | 
+----+---------------------------------------------------------------------------+ 
1 row in set (0.00 sec) 

その後、

mysql> update foo set bar = REPLACE(bar,'\\\\\\','') where id = 1; 
Query OK, 1 row affected (0.00 sec) 
Rows matched: 1 Changed: 1 Warnings: 0 

mysql> select * from foo; 
+----+------------------------------------------------------------------------+ 
| id | bar                 | 
+----+------------------------------------------------------------------------+ 
| 1 | Walgreens (www.walgreens.com) is the nation's largest drugstore chain. | 
+----+------------------------------------------------------------------------+ 
1 row in set (0.00 sec) 
+0

はそれをやったこと、ありがとうございます! – EmmyS

関連する問題