方法1:
SELECT
`a1`.`*`
FROM
`test` `a1`
LEFT JOIN `test` `a2`
ON `a2`.`t1` = `a1`.`t1`
AND `a2`.`t2` = 0
WHERE `a2`.`id` IS NULL;
方法2:
SELECT
*
FROM
`test`
WHERE `t1` IN
(SELECT
`t1`
FROM
`test`
GROUP BY `t1`
HAVING COUNT(IF(`t2` = 0, 1, NULL)) = 0);
方法3:
SELECT
`a1`.`*`
FROM
`test` `a1`
WHERE NOT EXISTS
(SELECT
`id`
FROM
`test` `a2`
WHERE `a2`.`t1` = `a1`.`t1`
AND `a2`.`t2` = 0);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…