sql 修改查询结果的值给接下来的查询用,但是不更改数据库中的值
2020-04-16 13:00 ZealouSnesS 阅读(1344) 评论(0) 编辑 收藏 举报参考:
https://blog.csdn.net/qq_30815327/article/details/79714551
https://blog.csdn.net/jiwenyi163/article/details/2794038
两种方法
方案一
case when
SELECT * FROM test; a --- 1 2 3 SELECT a, CASE WHEN a=1 THEN 'one' WHEN a=2 THEN 'two' ELSE 'other' END FROM test; a | case ---+------- 1 | one 2 | two 3 | other
方案二
replace关键字
SELECT * FROM table_name
Name | Age | Phone |
---|---|---|
ahuang | 18 | 13222100000 |
ahong | 19 | 13222100001 |
azi stripes | 22 | 13222100002 |
SELECT name,age,replace(phone,'1322','1380') FROM table_name
Name | Age | Phone |
---|---|---|
ahuang | 18 | 13802100000 |
ahong | 19 | 13802100001 |
azi stripes | 22 | 13802100002 |