假设您要检查是否有任何行与查询匹配(如果表包含任何匹配项,则只是真/假)。哪个是首选(并且可选地,为什么)?或者,还有更好的方法?
SELECT COUNT(*) > 0 FROM someTable WHERE someField = someValue
或者
SELECT someField = someValue FROM someTable WHERE someField = someValue LIMIT 1
或者
SELECT COUNT(*) > 0 FROM (SELECT someValue FROM someTable WHERE someField = someValue LIMIT 1) someAlias;