কম্পিউটার টিউটোরিয়াল

MySQL কলামে নির্দিষ্ট স্ট্রিং কতবার এসেছে তা গণনা করা

টেবিল তৈরি করা

mysql> create table DemoTable704 (SubjectName text); 
Query OK, 0 rows affected (0.58 sec)

রেকর্ড ইনসার্ট করা

mysql> insert into DemoTable704 values('Introduction to MySQL'); 
Query OK, 1 row affected (0.15 sec) 
mysql> insert into DemoTable704 values('Introduction to MongoDB'); 
Query OK, 1 row affected (0.17 sec) 
mysql> insert into DemoTable704 values('Introduction to MySQL'); 
Query OK, 1 row affected (0.31 sec) 
mysql> insert into DemoTable704 values('Introduction to Java'); 
Query OK, 1 row affected (0.39 sec) 
mysql> insert into DemoTable704 values('Introduction to MongoDB'); 
Query OK, 1 row affected (0.14 sec) 
mysql> insert into DemoTable704 values('Introduction to MySQL'); 
Query OK, 1 row affected (0.13 sec) 
mysql> insert into DemoTable704 values('Introduction to C'); 
Query OK, 1 row affected (0.08 sec) 
mysql> insert into DemoTable704 values('Introduction to Spring and Hibernate'); 
Query OK, 1 row affected (0.12 sec)

সকল রেকর্ড প্রদর্শন

mysql> select *from DemoTable704;

আউটপুট

+--------------------------------------+ 
| SubjectName                          | 
+--------------------------------------+ 
| Introduction to MySQL                | 
| Introduction to MongoDB              | 
| Introduction to MySQL                | 
| Introduction to Java                 | 
| Introduction to MongoDB              | 
| Introduction to MySQL                | 
| Introduction to C                    | 
| Introduction to Spring and Hibernate | 
+--------------------------------------+ 
8 rows in set (0.00 sec)

"Introduction to MySQL" কতবার এসেছে তা গণনার কোয়েরি

mysql> SELECT COUNT(*) from DemoTable704 WHERE SubjectName LIKE '%Introduction to MySQL%';

আউটপুট

+----------+ 
| COUNT(*) | 
+----------+ 
| 3        | 
+----------+ 
1 row in set (0.00 sec)
  1. MySQL-এ কলাম মানের সামনে স্ট্রিং প্রিপেন্ড (prepend) কীভাবে করবেন?

  2. MySQL-এ নির্দিষ্ট কলামে মান কতবার হয়েছে তা গুনতে COUNT() ও GROUP BY

  3. MySQL-এ TIME কলামের গড় (Average) বের করা

  4. Java-এ MySQL ResultSet থেকে কলাম নাম পাওয়া