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

MySQL-এ HAVING LENGTH() ব্যবহার করে স্ট্রিং দৈর্ঘ্য অনুযায়ী ফিল্টার করা

প্রথমে একটি টেবিল তৈরি করা যাক:

mysql> create table DemoTable ( 
  Title text ); Query OK, 0 rows affected (0.39 sec)

টেবিলে কিছু রেকর্ড ইনসার্ট করুন:

mysql> insert into DemoTable values('Introduction to MySQL'); Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('Introduction to Java'); Query OK, 1 row affected (0.09 sec)
mysql> insert into DemoTable values('Introduction to SQL'); Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values('Introduction to Python'); Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values('Introduction to SQL'); Query OK, 1 row affected (0.09 sec)
mysql> insert into DemoTable values('Introduction to Java'); Query OK, 1 row affected (0.13 sec)

টেবিলের সকল রেকর্ড দেখান:

mysql> select *from DemoTable;

এটি নিচের আউটপুট দেবে:

+------------------------+
| Title                  |
+------------------------+
| Introduction to MySQL  |
| Introduction to Java   |
| Introduction to SQL    |
| Introduction to Python |
| Introduction to SQL    |
| Introduction to Java   |
+------------------------+
6 rows in set (0.00 sec)

MySQL-এ HAVING LENGTH(field) ব্যবহার করে ২১ ক্যারেক্টারের চেয়ে ছোট টাইটেল ফিল্টার করার কোয়ারী:

mysql> select *from DemoTable group by length(Title) having length(Title) < 21;

এটি নিচের আউটপুট দেবে ('Introduction to SQL' = ১৯, 'Introduction to Java' = ২০):

+----------------------+
| Title                |
+----------------------+
| Introduction to SQL  |
| Introduction to Java |
+----------------------+
2 rows in set (0.00 sec)
  1. MySQL SLEEP() ফাংশন কি বিজি-ওয়েট? কীভাবে ইমপ্লিমেন্ট করবেন?

  2. MySQL-এ ইউজার-ডিফাইনড ভেরিয়েবল দিয়ে দুটি কলামের মান সোয়াপ করা

  3. MySQL-এ CHAR ফিল্ডকে DATETIME ফিল্ডে কনভার্ট করা

  4. MySQL에서 DOUBLE 타입 길이와 소수점 자릿수 지정하기