Reputation: 1
I need to write a SQL query which can fetch a data from one table A.
Senario - Lets take table A has only two column C1 and C2. C1 has row_id's and C2 has vaues like "Site=google;site=gmail,site=yahoo"
Requirment - Need to write a query which can fetch all the row_id from column C1 of table A but the value should come for column C2 as "google;gmail;yahoo". Means it should not show "Site=" for all the values of C2 column in the data fetch. And one more condition that if there is , in place of ; in the value then query should convert it into ; and show the data.
Upvotes: 0
Views: 318
Reputation: 50067
How about this:
SELECT C1, REPLACE(REPLACE(C2, 'Site=', ''), ',', ';') AS C2
FROM TABLE
Share and enjoy.
Upvotes: 4