为此,请在MySQL中使用LEFT。让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Title text -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('Java database connectivity to MySQL database'); mysql> insert into DemoTable values('Python with django framework'); mysql> insert into DemoTable values('C with data structure and algorithm');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+----------------------------------------------+ | Title | +----------------------------------------------+ | Java database connectivity to MySQL database | | Python with django framework | | C with data structure and algorithm | +----------------------------------------------+ 3 rows in set (0.00 sec)
以下是从MySQL左侧获取一些单词的查询-
mysql> select left(Title,10) as Title from DemoTable;
这将产生以下输出-
+-----------------+ | Title | +-----------------+ | Java datab | | Python wit | | C with dat | +-----------------+ 3 rows in set (0.00 sec)