作为替代答案只能用LOCATE
和SUBSTRING
,并在报价中不存在(例如像,如果返回null你只有theme1和theme2,或者如果你只有theme1,或者你没有任何主题)。你可以试试这个疯狂的一个(sqlFiddle)
SELECT theme,
SUBSTRING(theme,IF(LOCATE('"',theme)=0,NULL,LOCATE('"',theme))+1,
IF(LOCATE('"',theme,LOCATE('"',theme)+1)=0,NULL,LOCATE('"',theme,LOCATE('"',theme)+1))-
IF(LOCATE('"',theme)=0,NULL,LOCATE('"',theme))-1) as theme1,
SUBSTRING(theme,IF(LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)=0,NULL,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1))+1,
IF(LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)+1)=0,NULL,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)+1))-
IF(LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)=0,NULL,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1))-1) as theme2,
SUBSTRING(theme,IF(LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)+1)+1)=0,NULL,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)+1)+1))+1,
IF(LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)+1)+1)+1)=0,NULL,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)+1)+1)+1))-
IF(LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)+1)+1)=0,NULL,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme,LOCATE('"',theme)+1)+1)+1)+1))-1) as theme3
FROM table1
,如果你总是有3个主题,然后使用对方的回答,这是干净多了:)
你必须使用大量locate'的'和'substr'电话提取字符串的每个部分。如果您执行一些搜索,则可以找到可用于使其更容易的正则表达式UDF。 – Barmar