日期:2014-05-16 浏览次数:20701 次
mysql> create table hj89 (mem_id integer primary key, mem_username varchar(32), parent_cp_member_active varchar(32)); Query OK, 0 rows affected (0.17 sec) mysql> insert into hj89 values(32687, '张三', 32457); Query OK, 1 row affected (0.06 sec) mysql> insert into hj89 values(32457, '李四', 32687); Query OK, 1 row affected (0.05 sec) mysql> select mem_id, mem_username, (select mem_username from hj89 where mem_id = c.parent_cp_member_active) from hj89 c; +--------+--------------+--------------------------------------+ | mem_id | mem_username | (select mem_username from hj89 where mem_id = c.parent_cp_member_active) | +--------+--------------+--------------------------------------+ | 32457 | 李四 | 张三 | | 32687 | 张三 | 李四 | +--------+--------------+--------------------------------------+ 2 rows in set (0.03 sec)