MySQL建立計算欄位
阿新 • • 發佈:2021-01-07
拼接欄位
SELECT CONCAT(vend_name, ' ( ', vend_country, ' ) ') FROM vendors ORDER BY vend_name;
SELECT TRIM(CONCAT(vend_name, ' ( ', vend_country, ' ) ')) AS vend_title FROM vendors ORDER BY vend_name;
SELECT RTRIM(CONCAT(vend_name, ' ( ', vend_country, ' ) ')) AS vend_title FROM vendors ORDER BY vend_name;
執行算術計算
SELECT * FROM orderitems WHERE order_num = 20008;
SELECT prod_id, quantity, item_price, quantity*item_price AS expanded_price FROM orderitems WHERE order_num = 20008;