码迷,mamicode.com
首页 > 数据库 > 详细

创建数据库计算字段

时间:2019-10-01 16:42:13      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:创建   字段   eid   student   创建数据库   ems   HERE   price   one   

拼接两个列,使用concat()函数来实现


select concat(id,name)
from student
order by id;

输出结果为:
concat(id,name)

1luzhaoshan
2liumeidi
3luxinyan
4luchuanhang

使用别名as

select concat(id,name) as student_title
from student
order by id;

输出结果为:
 student_title

1luzhaoshan
2liumeidi
3luxinyan
4luchuanhang

select id,item_price,
id*item_price as money
from orderitems
where id = 1;

查找的结果是:
id    |    item_price    |    money

1     |    2.5                |    2.5

创建数据库计算字段

标签:创建   字段   eid   student   创建数据库   ems   HERE   price   one   

原文地址:https://www.cnblogs.com/ludundun/p/11614063.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!