我这里有这个脚本
select distinct
FirstName,
LastName,
table_2.status,
'Shop' as receiver
from table_1
inner join table_2 on table_1.key_2 = table_2.'SHOP-'id
order by FirstName, LastName
key_2字段有像SHOP-121这样的ID,而表2中的id就是数字121.
如何从key_2中删除SHOP-或将SHOP-添加到id?
答案 0 :(得分:5)
使用CONCAT
table_1.key_2 = CONCAT('SHOP-', table_2.id)
请记住,这将执行全表扫描,导致它在大型数据库上变慢。