TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

An Efficient Way to Check for Existence of Multiple Values in SQL

1 点作者 nalgeon超过 1 年前

1 comment

gregjor超过 1 年前
Using EXISTS (or NOT EXISTS) instead of COUNT() is both a well-know technique among trained DBAs and people with relational database experience, and something I rarely see developers use. I often rewrite existence or duplicate checking queries to eliminate the COUNT() and replace with EXISTS.<p>The author uses SELECT 1 in the example. The usual idiom is SELECT *, and query planners recognize EXISTS (SELECT * ...) and don&#x27;t actually select any columns.