SELECT DISTINCT jp.skills
FROM job_profile jp
UNION
SELECT js.skills
FROM job_seeker_profile js
The result:
|skills |
|php |
|PHP,Jquery,MVC |
|java |
|.net |
|Tally |
|php, mysql, yii |
|css, html, bootstrap|
|javascript, json |
but I need this as each item as row (each comma separated values as rows)
Expected result:
|skills |
|yii |
|PHP |
|Jquery |
|MVC |
|.net |
|Tally |
|bootstrap|
|css |
|html |
Create a split function which will split the data on , then create row wise data
SELECT distinct Split.fn.value('.', 'VARCHAR(100)') AS skills
FROM
(SELECT CAST ('<a>' + REPLACE(skills, ',', '</a><a>') + '</a>' AS XML) AS Data
FROM job_profile
) AS A CROSS APPLY Data.nodes ('/a') AS Split(fn);
Note: Update the inner query according to your need
Updated : In your case query will be
SELECT distinct Split.fn.value('.', 'VARCHAR(100)') AS skills
FROM
(SELECT CAST ('<a>' + REPLACE(jp.skills, ',', '</a><a>') + '</a>' AS XML) AS Data
FROM job_profile jp
UNION
SELECT js.skills
FROM job_seeker_profile js
) AS A CROSS APPLY Data.nodes ('/a') AS Split(fn);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.