如何在select查询中使用两个表值替换值 [英] How to replace a value using two table values in select query

查看:58
本文介绍了如何在select查询中使用两个表值替换值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两张桌子。



一张桌子包含以下数值。



I have two table.

one table contain below values.

itmID itmName
1 SE
2 TR
3 AV
4 LV





第二个表包含类似..





second table contain like..

screen
1:2
3:4
1:2:4:3
1:4:2
4:2





现在我想要使用SELECT语句显示我的输出,如下面的格式。





now i want to display my output like below format using SELECT statement.

SE:TR
AV:LV
SE:TR:LV:AV
SE:LV:TR
LV:TR

推荐答案

首先,糟糕的桌子设计!您需要重新考虑并重新设计。



您可以使用 REPLACE [ ^ ]函数。

First of all, bad tables design! You need to rethink it and redesign.

You can achieve that using REPLACE[^] function.
SELECT REPLACE(REPLACE(REPLACE(REPLACE(screens, '1', 'SE'), '2', 'TR'), '3', 'AV'), '4', 'LV') AS 'NewScreens'
FROM screen


这篇关于如何在select查询中使用两个表值替换值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆