এজন্য CASE স্টেটমেন্ট ব্যবহার করুন।
টেবিল তৈরি করা
mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (0.61 sec)
রেকর্ড ইনসার্ট করা
mysql> insert into DemoTable values('My name is John and this is my first tutorial on MySQL');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('This is Carol and I work on MongoDB');
Query OK, 1 row affected (0.19 sec)
সকল রেকর্ড প্রদর্শন
mysql> select *from DemoTable;
আউটপুট
+--------------------------------------------------------+ | Title | +--------------------------------------------------------+ | My name is John and this is my first tutorial on MySQL | | This is Carol and I work on MongoDB | +--------------------------------------------------------+ 2 rows in set (0.00 sec)
১০ শব্দের বেশি হলে ডট যোগ করার কোয়ারী
mysql> select (case when substring_index(tbl.Title, ' ', 10) = tbl.Title then tbl.Title -> else concat(substring_index(tbl.Title, ' ', 10), '....................') -> end) AS AddDots -> from DemoTable tbl;
আউটপুট
+-------------------------------------------------------------------+ | AddDots | +-------------------------------------------------------------------+ | My name is John and this is my first tutorial.................... | | This is Carol and I work on MongoDB | +-------------------------------------------------------------------+ 2 rows in set (0.00 sec)