mysql数据加百分号_使用MySQL SELECT语句时,在每个值的末尾添加一个百分号(%)...
要在末尾添加百分號,請使用CONCAT()函數。讓我們首先創建一個表-mysql>?create?table?DemoTable
(
StudentId?int?NOT?NULL?AUTO_INCREMENT?PRIMARY?KEY,
StudentName?varchar(100),
StudentScore?int
);
使用插入命令在表中插入一些記錄-mysql>?insert?into?DemoTable(StudentName,StudentScore)?values('John',65);
mysql>?insert?into?DemoTable(StudentName,StudentScore)?values('Chris',98);
mysql>?insert?into?DemoTable(StudentName,StudentScore)?values('Robert',91);
使用select語句顯示表中的所有記錄-mysql>?select?*from?DemoTable;
這將產生以下輸出-+-----------+-------------+--------------+
|?StudentId?|?StudentName?|?StudentScore?|
+-----------+-------------+--------------+
|?????????1?|?John????????|?65???????????|
|?????????2?|?Chris???????|?98???????????|
|?????????3?|?Robert??????|?91???????????|
+-----------+-------------+--------------+
3?rows?in?set?(0.00?sec)
以下是使用MySQL SELECT語句在末尾向每個值添加百分號(%)的查詢-mysql>?select?StudentId,StudentName,concat(StudentScore,'%')?AS?StudentScore?from?DemoTable;
這將產生以下輸出-+-----------+-------------+--------------+
|?StudentId?|?StudentName?|?StudentScore?|
+-----------+-------------+--------------+
|?????????1?|?John????????|?65%??????????|
|?????????2?|?Chris???????|?98%??????????|
|?????????3?|?Robert??????|?91%??????????|
+-----------+-------------+--------------+
3?rows?in?set?(0.00?sec)
總結
以上是生活随笔為你收集整理的mysql数据加百分号_使用MySQL SELECT语句时,在每个值的末尾添加一个百分号(%)...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 新能源汽车相比燃油汽车的优劣势
- 下一篇: 2019年新能源汽车销量超120万 未