• SQL – Exists

    SQL – Exists

    SQL Exists Keyword Table Of Contents: What Is SQL Exists Keyword? Syntax Of SQL Exists. Examples Of SQL Exists. (1) What Is SQL Exists Keyword? The EXISTS operator is used to look for the existence of a row in a given table that satisfies a set of criteria. It is a Boolean operator that compares the result of the subquery to an existing record and returns true or false. The returned value is true, if the subquery fetches single or multiple records and false if no record is matched. It is used in the combination of the subquery and checks

    Read More

  • SQL – Having

    SQL – Having

    SQL Having Keyword Table Of Contents: What Is SQL having Keyword? Syntax Of SQL Having? Examples Of SQL Having. (1) What Is SQL Having Keyword? SQL HAVING clause is similar to the WHERE clause; they are both used to filter rows in a table based on conditions. However, the HAVING clause was included in SQL to filter grouped rows instead of single rows. These rows are grouped together by the GROUP BY clause, so, the HAVING clause must always be followed by the GROUP BY clause. It can be used with aggregate functions, whereas the WHERE clause cannot. (2) Syntax Of

    Read More

  • SQL – Group By

    SQL – Group By

    SQL – Group By Table Of Contents: What Is SQL Group By ? Syntax Of SQL Group By. Examples Of SQL Group By. (1) What Is SQL Group By? The GROUP BY statement groups rows that have the same values into summary rows, like “find the number of customers in each country”. The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result set by one or more columns. (2) Syntax Of SQL Group By? SELECT column_name(s) FROM table_name WHERE condition GROUP BY column_name(s) ORDER BY column_name(s); (3) Examples Of SQL Group By? Example-1 SELECT COUNT(CustomerID), Country FROM Customers GROUP

    Read More

  • SQL – Union

    SQL – Union

    SQL – Union Table Of Contents: What Is SQL Union? Syntax Of SQL Union. Examples Of SQL Union. (1) What Is SQL Union ? The UNION the operator is used to combine the result set of two or more SELECT statements. Every SELECT statement within UNION must have the same number of columns. The columns must also have similar data types The columns in every SELECT statement must also be in the same order (2) Syntax Of SQL Union ? Syntax: UNION Syntax SELECT column_name(s) FROM table1 UNION SELECT column_name(s) FROM table2; Syntax: UNION ALL Syntax SELECT column_name(s) FROM table1 UNION ALL SELECT column_name(s) FROM

    Read More

  • SQL – Self Join

    SQL – Self Join

    SQL Self Join Table Of Contents: What Is SQL Self Join? Syntax Of SQL Self Join. Examples Of SQL Self Join. (1) What Is SQL Self Join? When you are joining the same table to itself it’s called Self Join. (2) Syntax Of SQL Self Join Syntax: SELECT column_name(s) FROM table1 T1, table1 T2 WHERE condition; (3) Examples Of SQL Self Join Customer: Example-1: SELECT A.CustomerName AS CustomerName1, B.CustomerName AS CustomerName2, A.City FROM Customers A, Customers B WHERE A.CustomerID <> B.CustomerID AND A.City = B.City ORDER BY A.City;

    Read More

  • SQL – Full Outer Join

    SQL – Full Outer Join

    SQL Full Outer Join Table Of Contents: What Is SQL Outer Join? Syntax Of SQL Outer Join. Examples Of SQL Outer Join. (1) What Is SQL Outer Join? The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records. FULL OUTER JOIN and FULL JOIN are the same. (2) Syntax Of SQL Outer Join? Syntax: SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name = table2.column_name WHERE condition; (3) Examples Of SQL Outer Join? Customer: Orders: Example-1: SELECT Customers.CustomerName, Orders.OrderID FROM Customers FULL OUTER JOIN Orders ON Customers.CustomerID=Orders.CustomerID ORDER BY Customers.CustomerName; Note:  The FULL OUTER

    Read More

  • SQL – Right Join

    SQL – Right Join

    SQL – Right Join Table Of Contents: What Is SQL Right Join? Syntax Of SQL Right Join. Examples Of SQL Right Join. (1) What Is SQL Right Join? The RIGHT JOIN keyword returns all records from the right table (table2), and the matching records from the left table (table1). The result is 0 records from the left side if there is no match. (2) Syntax Of SQL Right Join Syntax: SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column_name; (3) Examples Of SQL Right Join Order: Employees: Example-1: SELECT Orders.OrderID, Employees.LastName, Employees.FirstName FROM Orders RIGHT JOIN Employees ON Orders.EmployeeID =

    Read More

  • SQL – Left Join

    SQL – Left Join

    SQL – Left Join Table Of Content: What Is SQL Left Join? Syntax Of SQL Left Join. Examples Of SQL Left Join. (1) What Is SQL Left Join? The LEFT JOIN keyword returns all records from the left table (table1), and the matching records from the right table (table2). The result is 0 records from the right side if there is no match. (2) Syntax Of SQL Left Join. Syntax: SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name = table2.column_name; (3) Examples Of SQL Left Join. Customer Table: Orders Table: Example-1: SELECT Customers.CustomerName, Orders.OrderID FROM Customers LEFT JOIN Orders ON

    Read More

  • SQL – Inner Join

    SQL – Inner Join

    SQL – Inner Joins Table Of Contents: What Is SQL Inner Join? Syntax Of SQL Inner Join. Examples Of SQL Inner Join. (1) What Is SQL Inner Joins? The INNER JOIN keyword selects records that have matching values in both tables. (2) Syntax Of SQL Inner Joins? SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name = table2.column_name; (3) Examples Of SQL Inner Joins? Order Table: Customer Table: Example-1: Joining Two Tables SELECT Orders.OrderID, Customers.CustomerName FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID; Example-2: Joining Three Tables SELECT Orders.OrderID, Customers.CustomerName, Shippers.ShipperName FROM ((Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID) INNER

    Read More

  • SQL – Joins

    SQL – Joins

    SQL – Joins Table Of Contents: What Are SQL Joins? Types Of SQL Joins. (1) What Are SQL Joins? SQL Joins allow us to work on multiple tables by joining them together based on a related column. By bringing tables together you can have more information about the item. (2) Types Of SQL Joins? (INNER) JOIN: Returns records that have matching values in both tables LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left

    Read More