How to Select Distinct rows in SQL ? – Programmerbay https://programmerbay.com A Tech Bay for Tech Savvy Mon, 04 Jul 2022 06:14:35 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 https://programmerbay.com/wp-content/uploads/2019/09/cropped-without-transparent-32x32.jpg How to Select Distinct rows in SQL ? – Programmerbay https://programmerbay.com 32 32 How to Select Distinct Rows in SQL ? https://programmerbay.com/select-distinct-statement-to-get-only-unique-records-from-table/ https://programmerbay.com/select-distinct-statement-to-get-only-unique-records-from-table/#respond Fri, 16 Aug 2019 17:09:00 +0000 https://www.programmerbay.com/select-distinct-statement-to-get-only-unique-records-from-table/

The SELECT DISTINCT statement would let you get only unique information from a field that consists lots of duplicate data. In other words, a field that contains  lots of repeated values, to ignore those repeated values the SELECT DISTINCT statement is used.

It won’t allow the column’s data to repeat more than a single time and it gives filtered information with optimization as it doesn’t fetch entire duplicate information (take less memory).

Syntax:

SELECT DISTINCT feild1,feild2,.. FROM  Table_name;

For Example:

Suppose you have a table namely as user_details:

distinct question


and if you want to fetch only non repeated value of gender field, the command would be:

SELECT DISTINCT gender FROM user_details; 

Output:

distinct

 

]]>
https://programmerbay.com/select-distinct-statement-to-get-only-unique-records-from-table/feed/ 0