有个应用需要返回多个table,
$query1 = "SELECT ProductID FROM Accessories,CPU,Drive,GraphicCard,HardDisk,Memory,Monitor,Motherboard,Other";
$results1 = mysql_query($query1, $connect)or die("Query database failed 3");while ($row1 = mysql_fetch_row($results1)) 




可是总说Query database failed
每个table里都有ProductID,如果把ProductID换成count(*)就没问题,
实在找不出哪有毛病,高手帮忙看看~~~~~~~

解决方案 »

  1.   

    是说用Accessories.ProductID, CPU.ProductID 的方法吗?
    有没有办法让他们结合在一起输出,就是只输出一行, 都是ProductID ?
      

  2.   


    SELECT ProductID FROM Accessories,CPUSELECT 表中的字段 FROM表
    你表中字段不明确
      

  3.   


    mysql> select * from cpu;
    +-----------+
    | productid |
    +-----------+
    |         1 |
    |         2 |
    |         3 |
    |         4 |
    +-----------+
    4 rows in set (0.00 sec)mysql> select * from drive;
    +-----------+
    | productid |
    +-----------+
    |         1 |
    |         2 |
    |         3 |
    +-----------+
    3 rows in set (0.00 sec)mysql> select concat(group_concat(distinct cpu.productid),',',
        -> group_concat(distinct drive.productid)) productids
        -> from cpu,drive;
    +---------------+
    | productids    |
    +---------------+
    | 1,2,3,4,1,2,3 |
    +---------------+
    1 row in set (0.00 sec)