当前位置:首页 > 数据库 > 正文

创建数据库计算字段

2020-03-01 数据库

拼接两个列,使用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

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/SQL/21404.html