access字段拆分查询

mark271828 2010-01-16 10:41:06
access数据库中有表orders,字段city,city格式例如:xx省-xx市-xx区,我的需求是按city的省-市distinct查询,就是查不同的省-市,不要读区
...全文
301 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzp4881 2010-01-19
  • 打赏
  • 举报
回复
select left(city,InstrRev(city,"-")-1) from orders group by left(city,InstrRev(city,"-")-1)
lzp4881 2010-01-19
  • 打赏
  • 举报
回复
select left(city,InstrRev(city,"-")) from orders group by left(city,InstrRev(city,"-"))
mark271828 2010-01-19
  • 打赏
  • 举报
回复
最好能拆分第二个"-",因为“市”好多是没写的,"-"这个却固定
mark271828 2010-01-19
  • 打赏
  • 举报
回复
instr(city,"市")不是返回的0和1吗,left(city,instr(city,"市")) 用在这里是什么意思?不懂
  • 打赏
  • 举报
回复
select 这里得到你要查询的信息,记得要是唯一的 from orders group by left(city,InstrRev(city,"-",-1,1)-1)
plcc123 2010-01-16
  • 打赏
  • 举报
回复
split 不可以吗?首先
x=rs("city")
y=split(x,"-")
lzp4881 2010-01-16
  • 打赏
  • 举报
回复
select left(city,instr(city,"市")) from orders group by left(city,instr(city,"市"))
不耐烦 2010-01-16
  • 打赏
  • 举报
回复
分开保存最方便

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧