mysql - 附加查询参数不起作用

标签 mysql

Group By First Query in MySql

所以我提出了上述问题并得到了很好的答复

但是如何在 homematchingid !=0awaymatchingid !=0 中添加?

我已经尝试过以下方法,但都不起作用。

SELECT MIN(`Date`) AS `Date`, MIN(`Time`) AS `Time`,
    `HomeMatchingId`,`AwayMatchingId`,`RunningStatus`
FROM `20121208`
where `HomeMatchingId`!= 0,`AwayMatchingId`!= 0
GROUP BY `HomeMatchingId`,`AwayMatchingId`,`RunningStatus` 
HAVING `RunningStatus`= 1

SELECT MIN(`Date`) AS `Date`,MIN(`Time`) AS `Time`,
    `HomeMatchingId`,`AwayMatchingId`,`RunningStatus`
FROM `20121208`
GROUP BY `HomeMatchingId`,`AwayMatchingId`,`RunningStatus` 
HAVING `RunningStatus`=1,`HomeMatchingId`!=0,`AwayMatchingId`!=0);

最佳答案

您需要将 where 子句中的逗号替换为 AND 或 OR 等逻辑运算符。

SELECT MIN(`Date`) AS `Date`, MIN(`Time`) AS `Time`,
`HomeMatchingId`,`AwayMatchingId`,`RunningStatus`
FROM `20121208`
where `HomeMatchingId`!= 0 AND `AwayMatchingId`!= 0
GROUP BY `HomeMatchingId`,`AwayMatchingId`,`RunningStatus` 
HAVING `RunningStatus`= 1

关于mysql - 附加查询参数不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21308751/

相关文章:

php - 检索多个数据以 ListView ?

MySQL 随机连接表

java - 将 MySQL 表中的行与 Java 进行比较的最有效方法是什么

php - MySQL查询单行并从中获取值

mysql - 在 WHERE 关闭中转换不一致的 int/varchar

mysql - #1054 - 'content_type_video.field_video_file_fid' 中的未知列 'field list'

mysql - 如何在 MySQL 中选择唯一行后跟具有最高值的行?

javascript - tomcat App和数据库之间没有连接

mysql - 不同品类的数据库结构设计

mysql - 经典 ASP - 尝试检索特定值的总数