Condition (SQL)

From Infogalactic: the planetary knowledge core
Jump to: navigation, search


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

Types of condition

Lua error in package.lua at line 80: module 'strict' not found.

  • Many conditions compare values for (for example) equality, inequality or similarity.

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:

SELECT * FROM tab WHERE 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:

SELECT * FROM tab WHERE dk = 100 HAVING count(*) > 1

References

<templatestyles src="Reflist/styles.css" />

Cite error: Invalid <references> tag; parameter "group" is allowed only.

Use <references />, or <references group="..." />
  1. Lua error in package.lua at line 80: module 'strict' not found.
  2. Lua error in package.lua at line 80: module 'strict' not found.