Chapter Ten: Creating a calculated field

@author: Tobin
@date: 2019/10/28 19:51:40

Meaning the same field field and columns, the columns of the data processing form is converted to the client's needs.

# 拼接 MySQL用Concat()函数,多数DBM用+和||来实现拼接
SELECT Concat(vend_name, '(', vend_country,')')
FROM vendors
ORDER BY vend_name;

# Trim()函数,去除空格。LTrim(),RTrim()。
SELECT Concat(RTrim(vend_name), '(', RTrim(vend_country),')')
FROM vendors
ORDER BY vend_name;

# 使用别名,拼接完成的数据存到一个新列上,又称为导出列
SELECT Concat(RTrim(vend_name), '(', RTrim(vend_country),')') AS 
vend_title
FROM vendors
ORDER BY vend_name;

# + - * \
SELECT prod_id, quantity, item_price, quantity*item_price  AS 
expanded_price
FROM orderitems
WHERE order_num = 20005;

Guess you like

Origin www.cnblogs.com/zuotongbin/p/11814149.html