0

我在计算所有行时遇到问题。我的查询是:

SELECT info.pid, Name, Addr, Phone, GROUP_CONCAT(URL) as URL
FROM info, images WHERE info.pid = images.pid AND place='$kraj' GROUP BY info.pid

即使没有结果,我也不能使用mysql_num_rows因为创建了一行(空值)。group_concat()

我尝试放入COUNT()查询:

...GROUP_CONCAT(URL) as URL, COUNT(info.pid) as num FROM info...

但它为每个连接计算单独的行。

有什么建议么?

4

1 回答 1

0

为什么不过滤掉空值呢?:

SELECT info.pid, Name, Addr, Phone, GROUP_CONCAT(URL) as URL
  FROM info
  JOIN images
    ON info.pid = images.pid
 WHERE place = ...
   AND URL IS NOT NULL
 GROUP
    BY info.pid
;
于 2012-09-11T18:48:31.790 回答