如何在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 婚庆花篮祝福语简短大气