一个sql语句的问题

lovewei8543 2004-08-11 03:59:46
select M.* from Member as M join [active] as A on charindex(','+convert(nvarchar,M.id)+',',A.UserIDList)>0 where A.id = 8

上面的语句在sqlserver里可以正常执行

怎么把它传写成在access也支持的呢? (是不是access不支持charindex?)
...全文
129 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lovewei8543 2004-08-11
kingapex1(忘掉将来) ( ) 信誉:100 2004-8-11 16:33:46 得分: 0

这个好用

select M.* from Member as M join [active] as A on A.UserIDList like '%'+ m.id +'%' where A.id = 8

这个不准确 1 和 13 ??
回复
sheng9hhd 2004-08-11
试试-->
select M.* from Member as M join [active] as A on instr(A.UserIDList,','+convert(nvarchar,M.id)+',')>0 where A.id = 8
access里面可以用VB的函数
回复
kingapex1 2004-08-11
select M.* from Member as M inner join [active] as A on instr(A.UserIDList,',' & M.id & ',')>0 where A.id = 8

回复
eduxh 2004-08-11
select M.* from Member as M join [active] as A on charindex(','+convert(nvarchar,M.id)+',',A.UserIDList)>0 where A.id = 8
--------------------------------------------->
select M.* from Member as M join [active] as A on A.UserIDList like '%'+ m.id +'%' where A.id = 8
回复
pfc001 2004-08-11
都是SQl呀,不能直接用吗?没看到有T-SQL的关键词,难道是[]的问题?
回复
lovewei8543 2004-08-11
楼上的麻烦说的具体点 ?
谢谢
回复
skyboy0720 2004-08-11
没有那个函数,换成like
回复
lovewei8543 2004-08-11
其实我要实现这样的查询,先说下数据库结构 :

数据库是access的

Member 表
------------------
id
uid
pwd
.......
--------------------

active 表
--------------------
id
useridlist 会员id列表 用, 号个开 如: ,1,3,5,5,
------------------------

查询出 active 表里 id = 8 的所有会员信息

再sqlserver 里 这样就可以了 :
select M.* from Member as M join [active] as A on charindex(','+convert(nvarchar,M.id)+',',A.UserIDList)>0 where A.id = 8

但现在我的数据库是access的
回复
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-08-11 03:59
社区公告
暂无公告