Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Convert IDs to Values

$
0
0
Hi Guys,

I have got 2 tables:
User Table
UserID  Email        PublicationIDs
--------------------------
1   HR@test.com      11254|11255|11256|
2   Accts@test.com   11254|11256|
3   IT@test.com      11254|

Publication Table
PublicationID     Name     
-------------------
11254             Clinical 
11255             Dermatology
11256             Dental     

Now I want an output as below:

Email PublicationNames
1     Clinical|Dermatology|Dental|
2     Clinical|Dental|
3     Clinical|

Any ideas how to achieve the above results?

I have tried a condition like this, but it gives me an error:
SELECT usr.Email,usr.FirstName, GROUP_CONCAT(pub.SubCategoryName)
FROM dbo.CMS_User usr
INNER JOIN dbo.RR_PublicationSubCategories pub
ON FIND_IN_SET(pub.PublicationSubCategoriesID, usr.PublicationsNZ) > 0
GROUP BY usr.Email, usr.FirstName

Gives me an error msg:
'GROUP_CONCAT' is not a recognized built-in function name.

Your help is appreciated.

Thanks
Gitesh Shah


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>