题解 | #筛选出学校名中包含特定关键词的用户#
筛选出学校名中包含特定关键词的用户
https://www.nowcoder.com/practice/db591191caf2437592abebdbe437ae2b
介绍三种方法来实现:
# # 方法一:like # SELECT id,device_id,university # FROM user_profile # WHERE (university like '北京%' or university like '上海%') # and (university like '%学院' or university like '%校区') # and (university like '%职业%' or university like '%专科%' or university like '%成人%') # ; # # 方法二:rlike # SELECT id,device_id,university # FROM user_profile # WHERE university rlike '^(北京|上海).*(职业|专科|成人).*(学院|校区)$' # 方法三:regexp SELECT id,device_id,university FROM user_profile WHERE university regexp '^(北京|上海).*(职业|专科|成人).*(学院|校区)$'