When I run the below SQL, I'm getting results mentioned below:
SELECT distinct id,date,col_t FROM table1
WHERE col_t LIKE '%true%'
OR col_t LIKE '%https%'
OR col_t LIKE '%.html%'
OR col_t LIKE '%.html%'
OR col_t LIKE '%_____%'
OR col_t LIKE '%null%'
ID DATE COL_T
1 2022-02-02 true
2 2022-02-02 true
3 2022-02-02 PROMOTIONhttps://www.redbus.com/home
4 2022-02-02 google_goog_ob_27pc4https://www.google.com
5 2022-02-02 goog_gl_a1_store_id.html
6 2022-02-02 abc_xyz_def-example_____
7 2022-02-02 elp_car_parking_____
8 2022-02-02 elp1_car2_sum-grill_____
9 2022-02-02 two_abcd_slp_1_null_null_null_null
I want to replace true values with NULL and others with empty string ''.
Can I use REGEXP_REPLACE to get the desired output?
I tried using
REGEXP_REPLACE(COL_T,'\.html|http.*$|_null.*$|____.$|true','')
AS COL_T. But I'm not getting accurate results.The results should look like below:
ID DATE COL_T
1 2022-02-02 NULL
2 2022-02-02 NULL
3 2022-02-02 PROMOTION
4 2022-02-02 google_goog_ob_27pc4
5 2022-02-02 goog_gl_a1_store_id
6 2022-02-02 abc_xyz_def-example
7 2022-02-02 elp_car_parking
8 2022-02-02 elp1_car2_sum-grill
9 2022-02-02 two_abcd_slp_1