how to find unique element in sql
snippet in sql

how to find unique element in sql

user9639

DISTINCT
- select distinct * from employees; ==> 
           retrieves any row if it has at 
           least a single unique column.
- select distinct first_name from employees; ==> 
              retrieves unique names
              from table. (removes duplicates)
- select distinct count(*) from employees;
          retrieve number of unique rows
          if any row has at least a single unique data.

sql select unique

user6024

 SELECT DISTINCT column1, column2, ...

 FROM table_name; 

sql unique

user6667

-- To name a UNIQUE constraint, and to define a UNIQUE constraint on 
-- multiple columns, use the following SQL syntax:

-- MySQL / SQL Server / Oracle / MS Access:

CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    CONSTRAINT UC_Person UNIQUE (ID,LastName)
);