2012-01-26 15 views
5

में भागने वाले पात्रों के साथ REPLACE का उपयोग करना मेरे पास एक वेबसाइट से सबमिट की गई जानकारी का डेटाबेस है। मुख्य स्तंभ डेटा Markdown का उपयोग कर प्रवेश किया, और कहा कि इस तरह दिखता है पाठ के बहुत सारे शामिल किया गया था:phpMyAdmin

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