如何在MySQL中仅显示总值中的200个字符?
您可以使用LEFT()MySQL来显示MySQL整个值中的某些字符。以下是语法:
select left(yourColumnName ,200 ) AS anyAliasName from yourTableName;
让我们首先创建一个表:
mysql> create table DemoTable (Paragraph longtext);
以下是使用insert命令在表中插入记录的查询:
mysql> insert into DemoTable values('Introduction to Java,Introduction to C,Introduction to
C++,Introduction to Spring,Introduction to Hibernate,Introduction to Python,Introduction to
MySQL,Introduction to MongoDB,Introduction to SQL Server,Introduction to
ASP.net,Introduction to JSF');以下是使用select命令显示表中记录的查询:
mysql> select *from DemoTable;
这将产生以下输出:
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Paragraph | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Introduction to Java,Introduction to C,Introduction to C++,Introduction to Spring,Introduction to Hibernate,Introduction to Python,Introduction to MySQL,Introduction to MongoDB,Introduction to SQL Server,Introduction to ASP.net,Introduction to JSF | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
以下是查询,仅显示总值中的200个字符:
mysql> select left(Paragraph ,200) AS `200Characters` from DemoTable;
这将产生以下输出,仅显示前200个字符:
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 200Characters | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Introduction to Java,Introduction to C,Introduction to C++,Introduction to Spring,Introduction to Hibernate,Introduction to Python,Introduction to MySQL,Introduction to MongoDB,Introduction to SQL Ser | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短