sql语句查询语句问题,

SELECT CESHIXIANGMUMINGCHENG AS "国民",JIANCESHIJIAN AS "动脉硬化",ZONGHEPINGFEN AS "亚健康",BAOGAOURL AS "体成分",FPPGJIROULIANG AS "体成",CSSCDZZY AS "平衡",
CEDINGBUWEI AS "骨密度",SHUZHANGYA AS "血压计",CESHIFANGFA AS "心肺",BTGJXISHUZHI AS "平衡仪",KANGYANENGLI AS "精神" FROM t_users
RIGHT OUTER JOIN t_datacenter ON t_datacenter.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_tichengfen ON t_tichengfen.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_dongmaiyinghua ON t_dongmaiyinghua.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_gonglvche ON t_gonglvche.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_gumidu ON t_gumidu.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_pinghengyi ON t_pinghengyi.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_pinghengyigaoduan ON t_pinghengyigaoduan.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_tichengfengaoduan ON t_tichengfengaoduan.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_xueyaji ON t_xueyaji.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_yajiankang ON t_yajiankang.HUIYUANHAO = t_users.HUIYUANHAO
RIGHT OUTER JOIN t_jingshenyali ON t_jingshenyali.HUIYUANHAO = t_users.HUIYUANHAO
WHERE t_users.HUIYUANHAO="000850"

但是t_datacenter表中,会员号000850是有数据的,就是查不出来。
还是这个链接不行!!

3个回答

右连接以 right join 后的表为主 也就是 t_datacenter 为主, 既然 t_datacenter 有会员号000850是有数据的,你where 条件跟的是 t_users ,结果查不出数据,说明 t_users 这个表没有 000850 这个数据的, 换成 where t_datacenter.HUIYUANHAO="000850" 应该可以 右连接以右表为主

一条一条的 right join ,对比对比数据

你确认SQL逻辑正确吗?
既然是“是t_datacenter表中,会员号000850是有数据”,那么 WHERE 条件应该是 t_datacenter.HUIYUANHAO = '000850'(又:你是什么数据库?SQL字符串通常应该是单引号啊。)
既然关联关系是 t_datacenter -> t_users -> 其它表,那么除了第一个 RIGHT OUTER JOIN 之外,其它都应该是 LEFT OUTER JOIN

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!