প্রথমে একটি টেবিল তৈরি করা যাক:
mysql> create table DemoTable ( Name text ); Query OK, 0 rows affected (0.47 sec)
ইনসার্ট কমান্ড ব্যবহার করে টেবিলে কিছু রেকর্ড যোগ করুন:
mysql> insert into DemoTable values('John [John] Smith'); Query OK, 1 row affected (0.30 sec)
mysql> insert into DemoTable values('[Carol] Carol Taylor'); Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable values('David [Miller] Miller'); Query OK, 1 row affected (0.14 sec)
সিলেক্ট স্টেটমেন্ট ব্যবহার করে টেবিল থেকে সকল রেকর্ড প্রদর্শন করুন:
mysql> select *from DemoTable;
এটি নিম্নলিখিত আউটপুট দেবে:
+-----------------------+ | Name | +-----------------------+ | John [John] Smith | | [Carol] Carol Taylor | | David [Miller] Miller | +-----------------------+ 3 rows in set (0.00 sec)
বর্গাকার বন্ধনীর মাঝপথের টেক্সট সরানোর কোয়েরি:
mysql> select replace(Name,substring(Name,locate('[', Name), LENGTH(Name) - locate(']', reverse(Name)) - locate('[', Name) + 2), '') as Name from DemoTable;
এটি নিম্নলিখিত আউটপুট দেবে:
+---------------+ | Name | +---------------+ | John Smith | | Carol Taylor | | David Miller | +---------------+ 3 rows in set (0.03 sec)