Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Select Unique in SQL

Select Unique in SQL

SELECT UNIQUE in SQL

The UNIQUE keyword in a SELECT statement is used to return distinct rows — that is, it eliminates duplicate rows from the result set.


Overview

  • SELECT UNIQUE is functionally equivalent to SELECT DISTINCT.

  • It is mainly supported in Oracle and some other databases.

  • It ensures that the query returns only unique rows.


Syntax:

SELECT UNIQUE column1, column2, ...FROM table_nameWHERE condition;

Example:

Suppose you have a students table with multiple rows having the same city values.

SELECT UNIQUE cityFROM students;

This query will return each city only once, no duplicates.


Equivalent using DISTINCT (more common):

SELECT DISTINCT cityFROM students;

Notes:

  • Both UNIQUE and DISTINCT remove duplicate rows.

  • DISTINCT is supported by nearly all SQL databases; UNIQUE is less common.

  • Use either to get unique values in a column or combination of columns.


If you want examples using multiple columns or complex queries with UNIQUE or DISTINCT, just ask!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql