Thursday, May 28, 2020

Split Column Data from Mysql


DROP TABLE W2A_FEE;

CREATE TABLE W2A_FEE (CSV_VALUE VARCHAR(100));

INSERT INTO W2A_FEE VALUES('2.85,9,9');

INSERT INTO W2A_FEE VALUES('2.00,9,9');

INSERT INTO W2A_FEE VALUES('2.00,9,9');

INSERT INTO W2A_FEE VALUES('3.5,9,9');

 

SELECT CSV_VALUE FROM W2A_FEE;

 

SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(CSV_VALUE, ',', 1), ',', -1) AS Fee,
       SUBSTRING_INDEX(SUBSTRING_INDEX(CSV_VALUE, ',', 2), ',', -1) AS CGST,
       SUBSTRING_INDEX(SUBSTRING_INDEX(CSV_VALUE, ',', 3), ',', -1) AS SGST
FROM   W2A_FEE;

No comments:

Post a Comment