简体   繁体   中英

How extract word from string in sql

I have one table which contains column 'description'.Description contains strings, for example @abc will have @wxyz .

I want result { abc,wxyz } using sql query.

Thank you in advance.

Edited the answer, this might help you

SET @Description ='@abcd will have @xyz';
SELECT CONCAT('{',SUBSTRING(@Description, LOCATE('@', @Description), LOCATE(' ', @Description)),',', SUBSTRING( @Description,LOCATE(' @', @Description), LENGTH(@Description) - LOCATE(' @', @Description)), '}');

You can replace @Description with your column name! Hope this helps...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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