oracle query duplicate data of a field and intercept characters, find character subscripts

select b.* ,b.rowid from a_a_nm_shop_12 b right join
(select shop_url From a_a_nm_shop_12 c Group by shop_url having Count(shop_url) > 1 ) T
on b.shop_url = T.shop_url where platform_code ='002'

select substr(ent_url, INSTR(ent_url,'.',1,1), length(ent_url)) as time from z_huhehaote_ent_item



1. Splice string

1) You can use "||" to splice string

1 select 'Splice'||'String' as str from dual 2) 1 select concat('concatenation', 'string') as str from dual
through the concat() function Note: Oracle's concat function only supports the method of two parameters, that is, only two parameters can be concatenated , if you want to splicing multiple parameters, you can use concat to nest, such as: 1 select concat(concat('splicing', 'multiple'), 'string') from dual 2. Intercept the string SUBSTR(string,start_position , [length]) Seek substring, return string Explanation: string source string        start_position start position (starting from 0)










       length optional, the number of substrings

1 select substr(to_char(sysdate, 'yyyy-mm-dd HH:mi:ss'), 12, 5) as time from dual
1 substr("ABCDEFG", 0); //return: ABCDEFG, intercept all characters
2 substr("ABCDEFG", 2); //return: CDEFG, intercept all characters
3 starting from C substr("ABCDEFG", 0, 3); //return: ABC, Intercept 3 characters starting from A
4 substr("ABCDEFG", 0, 100); //Return: ABCDEFG, although 100 exceeds the maximum length of the preprocessed string, it will not affect the return result. Quantity returned.
5 substr("ABCDEFG", -3); //Return: EFG, pay attention to the parameter -3, when it is a negative value, it means that the string arrangement position is unchanged from the end.
3. Find the string

INSTR (string, subString, position, ocurrence) to find the position of the string

Explanation : string: the source string
        subString: the substring to be searched
        position: the starting position of the
        search ocurrence: the number of occurrences in the source string Substring

1 of select INSTR('CORPORATE FLOOR','OR', 3,


replace(strSource, str1, str2) Replace str1 in strSource with str2

Analysis: strSource: source string

     str1: string to be replaced

     str2: replaced string

1 select 'replace string' as oldStr, replace(' Replace string', 'replace', 'modify') as newStr from dual




-- intercept specified characters sql

update z_nutrient_food_elements a

set element24=substr(a.foodelements,instr(a.foodelements,'selenium'),9)

where a .foodelements like '%selenium%' and a.foodelements like '%selenium%'

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326482406&siteId=291194637