简体   繁体   English

需要编写一个SQL查询以从Oracle数据库中获取数据

[英]Need to write a SQL query to fetch data from a Oracle database

I need to write a SQL query which can fetch a data from one table A. 我需要编写一个SQL查询,该查询可以从一个表A中获取数据。

Senario - Lets take table A has only two column C1 and C2. Senario-让表A只有两列C1和C2。 C1 has row_id's and C2 has vaues like "Site=google;site=gmail,site=yahoo" C1具有row_id,C2具有诸如“ 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". 要求-需要编写一个查询,该查询可以从表A的列C1中获取所有row_id,但列C2的值应为“ google; gmail; yahoo”。 Means it should not show "Site=" for all the values of C2 column in the data fetch. 意味着对于数据提取中C2列的所有值,它都不应显示“ Site =“。 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. 分享并享受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM