所以我问上面的内容并得到了很好的回复
但如何添加homematchingid !=0
和awaymatchingid !=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);
答案 0 :(得分:1)
您需要使用AND或OR等逻辑运算符替换where子句中的逗号。
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
答案 1 :(得分:0)
尝试<>而不是!=
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
和
SELECT MIN(`Date`) AS `Date`,MIN(`Time`) AS `Time`,
`HomeMatchingId`,`AwayMatchingId`,`RunningStatus`
FROM `20121208`
GROUP BY `HomeMatchingId`,`AwayMatchingId`,`RunningStatus`
HAVING `RunningStatus`=1 AND `HomeMatchingId`<>0 AND `AwayMatchingId`<>0;
答案 2 :(得分:0)
试试这个
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
和
SELECT MIN(`Date`) AS `Date`,MIN(`Time`) AS `Time`,
`HomeMatchingId`,`AwayMatchingId`,`RunningStatus`
FROM `20121208`
GROUP BY `HomeMatchingId`,`AwayMatchingId`,`RunningStatus`
HAVING `RunningStatus`=1 AND `HomeMatchingId`<>0 AND `AwayMatchingId`<>0;