Sql Select Distinct Clause

Sql Select Distinct Clause

  • The Select Distinct  Clause is used to get different records.
  • If we have dublicate records,only one of them is listed.
  • The values of all listed columns must be exactly the same.
  • For to bring records faster,at the subqueries are used often.

Sql Select Distinct Syntax

Select distinct columnNames from tableName

Sql Select Distinct Examples on Library Database

TO DOWNLOAD THE SAMPLE LİBRARY DATABASE CLICK

Example 1: List all students name,but the same names are listed ones.

Select distinct name from students

Example 2: List all students class names,but the same class names are listed ones.

Select distinct class from students

Example 3: List the books, that the student named John has read. The same records are listed ones.

Select distinct books.* from books join borrows on books.bookId = borrows.bookId join students on borrows.studentId = students.studentId

YOU MAY WANT TO SEE OUR ALL EXAMPLES PAGE, THEN CLICK HERE

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: