SELECT a.id, a.name, b.ip FROM tabel1 as a, table2 as b WHERE a.id = 2;  a.id是主键, 唯一值, 我这样查询, 返回和数据表一样多条的相同记录 比如, a.id = 3,. 数据有5条记录, 就返回5条这样a.id = 3的记录  

解决方案 »

  1.   

    因为tabel1和table2两个表没有做关联,所有可能的组合都会查询出来。
      

  2.   

    myisam引擎的不能用关联 . . .
      

  3.   

    这里的关联就是指比如where a.id=b.aid这样子的关联关系,表的记录才能够对应起来呀!
      

  4.   

    SELECT a.id, a.name, b.ip FROM tabel1 as a, table2 as b WHERE a.id = 2; 等价于SELECT a.id, a.name, b.ip 
    FROM tabel1 as a, (select * from table2  WHERE a.id = 2) as b; 就是两个结果集的卡迪尔积,正确的做法应该加上table1和table2的关联关系,如SELECT a.id, a.name, b.ip FROM tabel1 as a, table2 as b 
    WHERE a.id=b.id and a.id = 2;