‘bar’ টেবিল থেকে ‘foo’ স্ট্রিংയুক্ত সকল রো ডিলিট করতে LIKE ওপারেটর ব্যবহার করতে হয়।
উদাহরণ
‘bar’ টেবিল তৈরি করি:
mysql> create table bar (
-> Id int NOT NULL AUTO_INCREMENT,
-> Words longtext,
-> PRIMARY KEY(Id)
-> ); Query OK, 0 rows affected (0.61 sec)
‘foo’ স্ট্রিংসহ রেকর্ড ইনসার্ট করি:
mysql> insert into bar(Words) values('Javafoo'); Query OK, 1 row affected (0.14 sec)
mysql> insert into bar(Words) values('fooMySQL'); Query OK, 1 row affected (0.19 sec)
mysql> insert into bar(Words) values('Introductiontofoo C and C++'); Query OK, 1 row affected (0.22 sec)
mysql> insert into bar(Words) values('Introduction to Node.js'); Query OK, 1 row affected (0.19 sec)
mysql> insert into bar(Words) values('Introduction to Hibernate framework'); Query OK, 1 row affected (0.17 sec)
ডেটা দেখি:
+----+-------------------------------------+ | Id | Words | +----+-------------------------------------+ | 1 | Javafoo | | 2 | fooMySQL | | 3 | Introductiontofoo C and C++ | | 4 | Introduction to Node.js | | 5 | Introduction to Hibernate framework | +----+-------------------------------------+
‘foo’ সম্বলিত রো ডিলিট করি (শুরু, মাঝপথ, শেষ—সব জায়গায়):
mysql> delete from bar where Words like '%foo' or Words like '%foo%' or Words like 'foo%'; Query OK, 3 rows affected (0.20 sec)
বचे থাকা রেকর্ড:
+----+-------------------------------------+ | Id | Words | +----+-------------------------------------+ | 4 | Introduction to Node.js | | 5 | Introduction to Hibernate framework | +----+-------------------------------------+