开发者

Need to write a SQL query to fetch data from a Oracle database

开发者 https://www.devze.com 2023-02-12 17:17 出处:网络
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=yah

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开发者_JS百科 - 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.


How about this:

SELECT C1, REPLACE(REPLACE(C2, 'Site=', ''), ',', ';') AS C2
  FROM TABLE

Share and enjoy.

0

精彩评论

暂无评论...
验证码 换一张
取 消