2017-04-19 55 views
0

我有柱狀態的蜂巢表作爲如何刪除特殊字符後的值在蜂巢

**state** 
taxes, TX 
Washington, WA 
New York, NY 
New Jersey, NJ 

現在我想狀態欄分開,我希望把它寫在新的列

**state**    **code** 
taxes     TX 
Washington    WA 
New York    NY 
New Jersey    NJ 

回答

2
select split(state,',')[0]   as state 
     ,ltrim(split(state,',')[1]) as code 

from mytable 

+------------+------+ 
| state | code | 
+------------+------+ 
| taxes  | TX | 
| Washington | WA | 
| New York | NY | 
| New Jersey | NJ | 
+------------+------+ 
0

選擇SUBSTR(名稱,0,INSTR(姓名, '') - 1 ),substr(name,instr(name,',')+ 1,10)from aa