Search the Whole World Here.,.,

SQL - UNION Syntax




SELECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;

Note: The UNION operator selects only distinct values by default. To allow duplicate values, use the ALL keyword with UNION.

SQL - INNER JOIN Example




The following SQL statement will return all customers with orders:

Example

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;
Try it Yourself »
Note: The INNER JOIN keyword selects all rows from both tables as long as there is a 
match between the columns. If there are rows in the "Customers" table that do not have matches in "Orders", these customers will NOT be listed.

SQL - INNER JOIN Syntax





SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;
or:

SELECT column_name(s)
FROM table1
JOIN table2
ON table1.column_name=table2.column_name;
PS! INNER JOIN is the same as JOIN.

SQL INNER JOIN

Different SQL JOINs





Before we continue with examples, we will list the types of the different SQL JOINs you can use:
  • INNER JOIN: Returns all rows when there is at least one match in BOTH tables.
  • LEFT JOIN: Return all rows from the left table, and the matched rows from the right table.
  • RIGHT JOIN: Return all rows from the right table, and the matched rows from the left table.
  • FULL JOIN: Return all rows when there is a match in ONE of the tables.

SQL - NOT BETWEEN Operator with Text Value Example




The following SQL statement selects all products with a ProductName beginning with any of the letter NOT BETWEEN 'C' and 'M':

Example

SELECT * FROM Products
WHERE ProductName NOT BETWEEN 'C' AND 'M';

Try it Yourself »

Ads by Google