mysql - 为 select 语句添加前缀文本

标签 mysql string-concatenation

我正在尝试在具有一些匹配主键的两个不同服务器上运行 select 语句。我希望能够选择主键,但向每条记录添加前缀“A”

例如:

ID   "to this"   ID
1                A1
2                A2
3                A3

这就是我的查询内容

select 'A' + CAST (a.id AS VARCHAR(25)) as ID,a.*,':',     b.*,':',c.*,':', d.*,':', e.*,'REPORTDT', g.*
from labgen.order_ a
join patient b on a.id = b.chart
join insurance c on b.ins1 = c.code
join client d on d.num = a.client1
join salesgrp e on d.salesgroup = e.num
join reportdt g on a.accession = g.accession

最佳答案

在 select 语句中试试这个:

select CONCAT('A', a.id) as ID, a.*,':', //etc

This链接也会有帮助。

关于mysql - 为 select 语句添加前缀文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39474599/

相关文章:

powershell - 如何在传递给函数的Powershell中附加字符串

java - 如何在java中连接int值?

python - 如何从 Python 中的串联子字符串索引中删除空格?

mysql - 从数据库中删除表如何影响 View

php - 使用 session 数据用户 ID 进行条件检查在 Codeigniter 中不起作用的情况

mysql - 查询具有不同值的相同列

reporting-services - SSRS 中表达式中的粗体特定值

mysql - 即使 MySQL 重新启动,如何设置全局 event_scheduler=ON?

php - Laravel - 显示 2 个表中的信息

sql - 如何在 SQL WHERE 子句中连接字符串