SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;
SQL Aliases
SQL aliases are used to give a table, or a column in a table, a temporary name.
Aliases are often used to make column names more readable.
An alias only exists for the duration of that query.
An alias is created with the AS keyword.
SELECT column_name(s) FROM table_name AS alias_name;
SQL JOIN
A JOIN clause is used to combine rows from two or more tables, based on a related column between them.
Let's look at a selection from the "Orders" table:
Example
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
Let's look at a selection from the "Orders" table:
OrderID
CustomerID
OrderDate
10308
2
1996-09-18
10309
37
1996-09-19
10310
77
1996-09-20
Then, look at a selection from the "Customers" table:
Inner join da select dan keyin ekranga chiqarilishi kerak bo’lgan maydon nomlari yoziladi.
From va inner join dan keyin ikkita jadval nomlari yoziladi. Bunda ularning qaysi biri birinchi yozilishi farq qilaydi, on dan keyin qaysi shar bajarilganda ekranga namoyish etilishi yoziladi.
Demak bizda quydagi yani “right join” va “left join”. Fromdan keyin yoziladigan table left join bo’ladi. (left or right ) join dan keyin keygan table right table xisoblanadi.
Shundan xulosa qilamizki yuqoridagi right joinda orders table ni hamma qiymatlarini contacts tableni esa faqatgina on dan keyin berilgan shartni qanoatlantiruvchilarinigina oladi.
SQL FULL OUTER JOIN Keyword
The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records.
Tip: FULL OUTER JOIN and FULL JOIN are the same.
FULL OUTER JOIN Syntax
SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name = table2.column_name WHERE condition;
Note: FULL OUTER JOIN can potentially return very large result-sets!