日期:2014-05-16 浏览次数:20800 次
mysql> select * from a; +------+----------+ | id | BIdes | +------+----------+ | 1 | 1,3,4,5 | | 2 | 2,4,8,10 | +------+----------+ 2 rows in set (0.00 sec) mysql> select * from b; +------+------+ | id | name | +------+------+ | 1 | A | | 2 | B | | 3 | C | | 4 | D | | 5 | E | +------+------+ 5 rows in set (0.00 sec) mysql> select b.* -> from A,b -> where a.id=1 And find_in_set(B.id,a.BIdes); +------+------+ | id | name | +------+------+ | 1 | A | | 3 | C | | 4 | D | | 5 | E | +------+------+ 4 rows in set (0.02 sec) mysql>
------解决方案--------------------
用你的数据:
select b.* from b left join b on instr(a.BIdes,B.id)>0 where a.id=1