इसके लिए REPLACE() फंक्शन का उपयोग करें और खाली स्थान को कैरेक्टर से रिप्लेस करें।
उदाहरण
टेबल बनाएं:
mysql> create table DemoTable (Subject text); Query OK, 0 rows affected (0.86 sec)
रिकॉर्ड डालें:
mysql> insert into DemoTable values('Introduction to MySQL');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values('Java in depth');
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable values('Data Structure and Algorithm');
Query OK, 1 row affected (0.16 sec)
सभी रिकॉर्ड देखें:
mysql> select * from DemoTable;
आउटपुट
+------------------------------+ | Subject | +------------------------------+ | Introduction to MySQL | | Java in depth | | Data Structure and Algorithm | +------------------------------+ 3 rows in set (0.00 sec)
खाली स्थान रिप्लेस करने की क्वेरी:
mysql> SELECT *, REPLACE(Subject, ' ', '_') as Subject_Name from DemoTable;
आउटपुट
+-------------------------------+------------------------------+ | Subject | Subject_Name | +-------------------------------+------------------------------+ | Introduction to MySQL | Introduction_to_MySQL | | Java in depth | Java_in_depth | | Data Structure and Algorithm | Data_Structure_and_Algorithm | +-------------------------------+------------------------------+ 3 rows in set (0.00 sec)
नोट: REPLACE(स्ट्रिंग, खोज_स्ट्रिंग, रिप्लेस_स्ट्रिंग) - सभी घटनाओं को रिप्लेस करता है।