Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 SQL 选择全选或全选,遵循以下条件:如果任何元组有一个值为 1 的列,则它必须返回空,但是如果所有元组的值都为 0,则返回所有元组。
你可以这样做:
SELECT * FROM MyTable WHERE (SELECT COUNT(*) FROM MyTable t WHERE t.MyColumn=1)=0
条件对所有行计算为真或假;如果其中有任何行1,则不会返回任何行。
1