日期:2014-05-16 浏览次数:20977 次
mysql> use test; Database changed mysql> create table t1(authority varchar(20)); Query OK, 0 rows affected (0.42 sec) mysql> create table t2( id int ,name varchar(20)); Query OK, 0 rows affected (0.32 sec) mysql> insert into t1 values(1),(2),(3); Query OK, 3 rows affected (0.31 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> insert into t2 values(1,"zhangsan"),(2,"lisi"),(3,"wangwu"); Query OK, 3 rows affected (0.30 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from t2 where id in (select authority from t1); +------+----------+ | id | name | +------+----------+ | 1 | zhangsan | | 2 | lisi | | 3 | wangwu | +------+----------+ 3 rows in set (0.03 sec)
------解决方案--------------------
select *
from 第二张表
where id in (select authority from 第一张表)
------解决方案--------------------
贴建表及插入记录的SQL,及要求结果出来看看
SELECT A.* FROM B1 A INNER JOIN B2 B ON A.ID=B.authority
------解决方案--------------------
select *
from table2
where id in (select authority from table1)
------解决方案--------------------
每次来做问答,发现我心中的答案总被一个狼头或者一个苹果上的企鹅说出来了
------解决方案--------------------
select *
from table2
where id in (select authority from table1)
这个就可以的呀
------解决方案--------------------
select * from db_groupuser a inner join db_authority b on find_in_set(b.id,a.authority)>0
这个不行?要求什么结果?