টেবিল তৈরি এবং ডেটা ইনসার্ট
mysql> create table DemoTable1854 ( Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)
mysql> insert into DemoTable1854 values('John-Smith'); Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1854 values('Chris-Brown'); Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1854 values('Adam-Smith'); Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1854 values('John-Doe'); Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1854 values('John-Smith'); Query OK, 1 row affected (0.00 sec)
সব রেকর্ড
mysql> select * from DemoTable1854;
+-------------+ | Name | +-------------+ | John-Smith | | Chris-Brown | | Adam-Smith | | John-Doe | | John-Smith | +-------------+ 5 rows in set (0.00 sec)
'John-' দিয়ে শুরু হওয়া নামগুলো এবং তাদের ফ্রিকোয়েন্সি
mysql> select Name, count(Name) from DemoTable1854 where Name like 'John-%' group by Name;
+------------+-------------+ | Name | count(Name) | +------------+-------------+ | John-Smith | 2 | | John-Doe | 1 | +------------+-------------+ 2 rows in set (0.00 sec)
ব্যাখ্যা: WHERE Klausule-এ LIKE 'John-%' দিয়ে ফিল্টার করা হয়েছে, তারপর GROUP BY এবং COUNT() দিয়ে প্রতিটি ভিন্ন নামের বারবার্বার্তা গণনা করা হয়েছে।