如果执行这个逻辑case when PlaceCode like 'shiqu%' then '370200' when PlaceCode like 'shinan%' then '370202' when PlaceCode like 'shibei%' then '370203' when PlaceCode like 'huangdao%' then '370211' when PlaceCode like 'laoshan%' then '370212' when PlaceCode like 'licang%%' then '370213' when PlaceCode like 'chengyang%' then '370214' when PlaceCode like 'kaifa%' then '370215' when PlaceCode like '%jichang%' then '370216' when PlaceCode like 'laixi%' then '370285' when PlaceCode like 'jiaozhou%' then '370281' when PlaceCode like 'jimo%' then '370282' when PlaceCode like 'pingdu%' then '370283' end应该怎么写呢
时间: 2023-07-29 15:07:15 浏览: 312
SHIQU.zip_OpenGL_Visual_C++_
你可以把这个case-when语句放在你的SQL语句中,如:
```
SELECT PlaceCode,
CASE
WHEN PlaceCode LIKE 'shiqu%' THEN '370200'
WHEN PlaceCode LIKE 'shinan%' THEN '370202'
WHEN PlaceCode LIKE 'shibei%' THEN '370203'
WHEN PlaceCode LIKE 'huangdao%' THEN '370211'
WHEN PlaceCode LIKE 'laoshan%' THEN '370212'
WHEN PlaceCode LIKE 'licang%%' THEN '370213'
WHEN PlaceCode LIKE 'chengyang%' THEN '370214'
WHEN PlaceCode LIKE 'kaifa%' THEN '370215'
WHEN PlaceCode LIKE '%jichang%' THEN '370216'
WHEN PlaceCode LIKE 'laixi%' THEN '370285'
WHEN PlaceCode LIKE 'jiaozhou%' THEN '370281'
WHEN PlaceCode LIKE 'jimo%' THEN '370282'
WHEN PlaceCode LIKE 'pingdu%' THEN '370283'
END AS PlaceCodeNew
FROM your_table;
```
这个语句会根据PlaceCode的值匹配对应的值,并返回一个新的列 PlaceCodeNew。
阅读全文