Archive for the Category: SQL Syntax

SQL CASE

SQL CASE is used to provide conditional (if-else) logic in SQL statements.

Leave a comment

SQL INTERSECT

The SQL INTERSECT query is similar to the SQL UNION query, also works on two SQL Select statements. The difference is that SQL UNION query selects rows either in the first or the second Select statement (like OR operator), while the SQL INTERSECT query selects rows in the both first and second Select statement (like [...]

2 Comments

SQL MINUS, SQL EXCEPT

SQL MINUS query or SQL EXCEPT query is used to subtract out the result of second query from the result of the first qeury. It takes the distinct result set of the first query, then filter out the records which appear in the result set of the second query. If the second query includes the [...]

Leave a comment

SQL UNION ALL

The SQL UNION ALL query is similar to SQL UNION query, it’s also used to merge two or more SQL SELECT query results. The difference is that SQL UNION returns distinct values, while SQL UNION ALL returns ALL the values.

1 Comment

SQL UNION

The SQL UNION query is used to merge two or more SQL SELECT query results. Each query statement should have same column structure: same number of columns, same or compatible data types and in same order. Note: The result of SQL UNION query is distinct.

Leave a comment

SQL OUTER JOIN

Unlike SQL INNER JOIN, SQL OUTER JOIN selects rows from 2 joined tables even there is no matches found. There are three kind of SQL OUTER JOINs: SQL LEFT OUTER JOIN SQL RIGHT OUTER JOIN SQL FULL OUTER JOIN

Leave a comment

SQL EXISTS

SQL EXISTS is used to test if a subquery returns a row or not. If yes, then the outer query proceeds, if not, the outer query stops and no row returned.

Leave a comment

SQL SELF JOIN

SQL SELF JOIN is a normal join which joins a table to itself. Note: SQL SELF JOIN can be any kind of joins: SQL INNER JOIN, SQL LEFT JOIN, SQL RIGHT JOIN, SQL FULL JOIN. And that SQL SELF JOIN itself is not an SQL keyword.

3 Comments

SQL FULL JOIN

SQL FULL JOIN clause is used to select all the matched records from either left or right side table.

Leave a comment

SQL RIGHT JOIN

SQL RIGHT JOIN clause is very similar with SQL LEFT JOIN clause, it is used to select all the matched records from the right side table, regardless if it has matched records in the left side table or not.

1 Comment