REGEXP_REPLACE() फ़ंक्शन
केवल पहली occurrence बदलने के लिए REGEXP_REPLACE() का उपयोग करें (MySQL 8.0+)।
उदाहरण
स्ट्रिंग: This is my first MySQL query. This is the first tutorial. I am learning for the first time.
"first" का पहला occurrence "second" से रिप्लेस करना है।
टेबल और डेटा
mysql> create table demo26 (value text);
mysql> insert into demo26 values('This is my first MySQL query. This is the first tutorial. I am learning for the first time.');
क्वेरी
mysql> update demo26 set value = REGEXP_REPLACE(value, 'first', 'second', 1, 1);
- पैरामीटर:
कॉलम, खोज_स्ट्रिंग, रिप्लेसमेंट, पोजीशन, occurrence 1, 1का अर्थ: पोजीशन 1 से शुरू करके पहली occurrence बदलें।
परिणाम
This is my second MySQL query. This is the first tutorial. I am learning for the first time.