sniper_nie 2016-03-22 01:59 采纳率: 0%
浏览 1279

mysql in子句问题请教

1、select role_auth_ids from test_role where role_name='经理' 的执行结果:
+------------+
role_auth_ids
+------------+
1,2,3

2、select auth_name from test_auth where auth_id in (1,2,3)的执行结果:
+------+
auth_name
+------+
商品管理
商品添加
商品编辑

但是,将1、2条语句合并后,即select auth_name from test_auth where auth_id in (select role_auth_ids from test_role where role_name='经理'),执行结果只有一条数据,也就是只有商品管理一个数据。这是why?

SELECT auth_name FROM test_auth WHERE auth_id IN (SELECT replace(concat('''',role_auth_ids,''''),',',''',''') FROM test_role WHERE role_name = '经理 ') 给in子句加上单引号也不行..................

请教各位大神我该如何才能从通过test_role中role_auth_ids查询出对应的test_auth表中的auth_name呢?

  • 写回答

6条回答 默认 最新

  • My_It5224 2016-03-22 02:14
    关注

    你将你的test_auth 和 test_role 表的关于这几个字段的具体数据列检索结果列一下吧

    评论

报告相同问题?

悬赏问题

  • ¥15 Java中消息和缓存如何使用
  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路