Trisha Shetty (Editor)

Condition (SQL)

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

A relational database management system uses SQL conditions or expressions in WHERE clauses and in HAVING clauses to SELECT subsets of data.

Contents

Types of condition

  • Many conditions compare values for (for example) equality, inequality or similarity.
  • The EXISTS condition uses the SQL standard keyword EXISTS to determine whether rows exist in a subquery result.
  • Examples

    To SELECT one row of data from a table called tab with a primary key column (pk) set to 100 — use the condition pk = 100:

    To identify whether a table tab has rows of data with a duplicated key column dk set to 100 — use the condition dk = 100 and the condition having count(*) > 1:

    References

    Condition (SQL) Wikipedia