ใช้ SUBSTRING(column, start, length) เริ่มนับจาก 1
ตัวอย่าง
mysql> create table DemoTable ( Information text ); Query OK, 0 rows affected (2.63 sec)
mysql> insert into DemoTable values('MySQL is a structured query language');
Query OK, 1 row affected (0.13 sec)
ข้อมูล
mysql> select * from DemoTable;
+--------------------------------------+ | Information | +--------------------------------------+ | MySQL is a structured query language | +--------------------------------------+
ดึง 10 ตัวอักษรแรก
mysql> select substring(Information,1,10) from DemoTable;
+-----------------------------+ | substring(Information,1,10) | +-----------------------------+ | MySQL is a | +-----------------------------+
รูปแบบ: SUBSTRING(str, pos, len) หรือ SUBSTR(str, pos, len) pos เริ่มที่ 1