Thursday, 15 February 2018

SQL Distinct statement

SQL SELECT DISTINCT Statement

SELECT DISTINCT statement is return only different data from SQL table

Syntax : SELECT DISTINCT column1, column2 FROM tablename

Example : SELECT DISTINCT City FROM tblCity (if city contains duplicate name DISTINCT not get that value)

How to use INNER JOIN in SQL Query

INNER JOIN Syntax

SELECT YourColumnName FROM YourTableName
INNER JOIN InnerTableName ON InnerTableName.Column = YourTableName.Column

Example

SELECT * FROM City
INNER JOIN Country ON Country.CountryID = City.CountryIDF

SQL JOIN use for combine rows in one or more tables in SQL

SQL Join types

1. INNER JOIN return that value if both column record match in table

2. LEFT OUTER JOIN return records match in left table and match right table

3. RIGHT OUTER JOIN return records match in right table and match left table

4. FULL OUTER JOIN return records match in left and right table