select p.fisrespposition from T_ORG_Position p , T_PM_USER u, T_ORG_PositionMember m
where p.fid=m.fpositionid and u.fid=m.fpersonid
and u.fid='rhyVpxOXQmuu22PFNCRuDRO33n8='RT,怎么查不出来结果呢
where p.fid=m.fpositionid and u.fid=m.fpersonid
and u.fid='rhyVpxOXQmuu22PFNCRuDRO33n8='RT,怎么查不出来结果呢
解决方案 »
- 请教一个sql
- 请问这样一个sql语句应该如何写?
- 求救有关SQL6.5的简单问题
- 关于把字符串分成几段的问题,十万火急!!
- 报错:[DBNETLIB][ConnectionRead (recv()).]一般性网络错误。请检查网络文档
- 数据库复制
- (高分请教弱问题)查询视图时where 条件为什么不管用??(顶着有分)
- 我在定义了一个table的主健以后,又准备修改他,请问如何写阿,(谢谢)
- 请问为什么我安装完sql server后,不能建立表,系统表内容也看不到?
- SQL SERVER查询条件问题
- SQL语句的问题,会的帮忙解决,不会的麻烦帮顶,谢谢....................
- shrinkdatabase和shrinkfile
p.fisrespposition
FROM
T_ORG_Position p,
T_PM_USER u,
T_ORG_PositionMember m
WHERE
p.fid = m.fpositionid
AND u.fid = m.fpersonid
AND u.fid = 'rhyVpxOXQmuu22PFNCRuDRO33n8='
--#1.看一下fid是不是nvarchar, 是的话加N''
--#2.语法没问题,注意自己的逻辑.自己单独查询一下吧
SELECT * FROM T_PM_USER WHERE fid = 'rhyVpxOXQmuu22PFNCRuDRO33n8='
SELECT * FROM T_ORG_PositionMember WHERE fpersonid = 'rhyVpxOXQmuu22PFNCRuDRO33n8='
SELECT * FROM T_ORG_Position WHERE fid IN
(
SELECT fpositionid FROM T_ORG_PositionMember WHERE fpersonid = 'rhyVpxOXQmuu22PFNCRuDRO33n8='
)
--step 1 关联T_PM_USER,T_ORG_PositionMember 是否存在要求的记录
select m.* into #temp_1 from T_PM_USER u inner join T_ORG_PositionMember m
on u.fid=m.fpersonid
where u.fid='rhyVpxOXQmuu22PFNCRuDRO33n8='
--step 2 显示符合要求的数据,如不要求数据,则是上述两表就不存在这样的数据
select * from #temp_1--step 3 借助中间表#temp_1,验证三表关系
select p.fisrespposition from #temp_1 a inner join T_ORG_Position p
on p.fid=a.fpositionid
select fisrespposition from T_ORG_Position p
where p.fid in
(select fpositionid from T_ORG_PositionMember m where m.fpersonid in
(select fpersonid from T_PM_USER where fid=''rhyVpxOXQmuu22PFNCRuDRO33n8='))
我又写成这样了,查出来了,问题在哪呢
你这个语句里的联结条件是
p.fid=m.fpositionid
and m.fpersonid=u.fpersonid
跟你最开始的联结条件p.fid=m.fpositionid and u.fid=m.fpersonid 是不一样的
where p.fid=m.fpositionid
and m.fpersonid=u.fpersonid
and u.fid='rhyVpxOXQmuu22PFNCRuDRO33n8='