Click here to Skip to main content
15,891,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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


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
Posted
Updated 24-Mar-13 21:11pm
v2

1 solution

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

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900