Structured Query Language SQL PART 2
Structured Query Language SQL PART 2
Instructor:
Mr. Francis Noel I. Alarcon, LPT, MS
Date and Time Functions – DATE_FORMAT
• Returns a character string or a formatted string from a date value
• DATE_FORMAT(date_value, fmt) *fmt = format used; can be:
• %M: name of month
• %m: two-digit month number
• %b: abbreviated month name
• %d: number of day of month
• %W: weekday name
• %a: abbreviated weekday name
• %Y: four-digit year
• %y: two-digit year
Date and Time Functions – YEAR, MONTH, DAY
• Returns a four-digit year
• YEAR(date_value)
• CONVERT(value-to-convert, decimal(l,d))
• Other than the data type to be converted into, these functions operate the
same as described above.
Conversion Functions – CASE
• Compares an attribute or expression with a series of values and returns
an associated value or a default value if no match is found
• CASE When condition
THEN value1 ELSE value2 END
Conversion Functions – CASE
• Compares an attribute or expression with a series of values and returns
an associated value or a default value if no match is found
• CASE When condition
THEN value1 ELSE value2 END
ALTER - Columns
• It is used to add, delete, or modify columns in an existing table.
• To delete a table
• DROP TABLE table_name;
UPDATE
• UPDATE tablename
SET columnname = expression [, columnname = expression]
[WHERE conditionlist ];
DELETE
• DELETE FROM tablename
[WHERE conditionlist ];