Select each record from the table without repeating one record

How to select each record without repeating the same record?

Example:

ID            item
------       -------
ABC          item 1
XXX          item 2
AXA          item 3
ABC          item 4
XXX          item 5

From the table above, I just want to select each entry, such as ABC, XXX and AXA, without repeating it. How to do it in MS SQL 2005?

+5
source share
7 answers

You must use the keyword "DISTINCT" to retrieve individual records, you can use the following query,

"SELECT DISTINCT ID FROM"

+2
source

Use the keyword distinct:

Select distinct id from TABLE;
+2
source
SELECT DISTINCT ID from YourTable
+2
Select Distinct ID from tablename
+2

DISTINCT () .

SELECT DISTINCT you_column_name FROM your_table_name
+2

DISTINCT () .

http://www.w3schools.com/sql/sql_distinct.asp

, :

SELECT DISTINCT ID FROM Table_name

+2
source

select a separate identifier from tablename

+1
source

All Articles