$rs = mysql_query('select a.*,b.* from tb1 as a,tb2 as b where a.id=b.tb1id');
while($row = mysql_fetch_assoc($rs)) {
  $res[] = $row;
}
print_r($res);

解决方案 »

  1.   

    select a.id,b.name from tb1 as a,tb2 as b where a.id=b.tb1id
      

  2.   


    这个我知道肯定能行,但是如果仪表有很多列要显示呢?并且要同时显示tb1和tb2两个表的ID,怎么在php语法中区分a.id和b.id呢?我隐隐约约记得老早写asp的时候可以在脚本中写的~~~
      

  3.   

    select a.id as aid,b.id as bid,b.name from tb1 as a,tb2 as b where a.id=b.tb1id
    取的时候aid表示tb1里的id,bid表示tb2表的id
      

  4.   


    这个我也知道,能输出数组,但是不能达到我的要求。比如我想要一个表:
    'select a.*,b.* from tb1 as a,tb2 as b where a.id=b.tb1id and b.name=''动画片';
    tb1                                                   tb2
    id       name                                    id      tb1id    name要怎么用php语法来区分a.id  a.name和b.id  b.name呢?
      

  5.   


    如果两个表重复的字段非常多,并且干脆字段完全相同,那么非要这么一个字段一个字段的写?我模模糊糊记得ASP是可以区分,忘了语法了,好像是类似rs("a.id")什么的,但是PHP测试不通
      

  6.   

    mysql_fetch_assoc 返回的是关联数组,很自然关联键是唯一的
    你可以用 mysql_fetch_row 返回下标数组,那就不会被覆盖了