sql select unique
snippet in sql

sql select unique

user4516

 SELECT DISTINCT column1, column2, ...

 FROM table_name; 

DISTINCT SQL

user1745

SELECT DISTINCT column1, column1, ..... FROM TABLE
/*DISTINCT WILL NOT SELECT THE SAME VALUES IN SAME COLUMN*/

query DISTINCT

user7957

SELECT DISTINCT Column_name FROM table_name;

sql unique

user746

-- 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)
); 

sql server select rows by distinct column

user4982

SELECT a.*
FROM emails a
INNER JOIN 
  (SELECT email,
    MIN(id) as id
  FROM emails 
  GROUP BY email 
) AS b
  ON a.email = b.email 
  AND a.id = b.id;