SQL Notes Week-4
SQL Notes Week-4
So, once a condition is true, it will stop reading and return the result. If no conditions are
true, it returns the value in the ELSE clause.
Syntax
CASE
WHEN condition1 THEN result1
WHEN condition2 THEN result2
WHEN conditionN THEN resultN
ELSE result
END;
• 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
UNION Syntax
SELECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;
SQL Function
String Function
YEARWEEK Returns the year and week number for a given date
Syntax
MySQL Views
In SQL, a view is a virtual table based on the result-set of an SQL statement.
A view contains rows and columns, just like a real table. The fields in a view are fields
from one or more real tables in the database.