420 likes | 679 Views
Built-in Functions. Usage of Wildcards. Most important built-in functions. How to take advantage of wildcards?. Databases Basics. SoftUni Team. Technical Trainers. Software University. http://softuni.bg. Table of Contents . String built in functions SQL Server/MySQL
E N D
Built-in Functions.Usage of Wildcards Most important built-in functions. How to take advantage of wildcards? Databases Basics SoftUni Team Technical Trainers Software University http://softuni.bg
Table of Contents • String built in functions SQL Server/MySQL • Math built in functions SQL Server/MySQL • Date built in functions SQL Server/MySQL • Other built in functions SQL Server/MySQL • Like + Wildcards
Questions sli.do#8594
LEN MySQL LEN(ColumnName) LENGTH(column_name) CHAR_LENGTH(column_name) SQL Server
CONCAT SQL Server/MySQL CONCAT(param1, param2, …, paramN)
LOWER / UPPER SQL Server/MySQL LOWER/UPPER(ColumnName)
LEFT / RIGHT LEFT/RIGHT (ColumnName, TakeQuantity) SQL Server/MySQL
LTRIM / RTRIM SQL Server/MySQL LTRIM/RTRIM(ColumnName) MySQL has TRIM function!
SUBSTRING SQL Server/MySQL SUBSTRING(ColumnName, StartIndex, Length)
CHARINDEX MySQL LOCATE(substr, str, position) CHARINDEX(substr, str, [position]) SQL Server
REPLACE REPLACE(StringExpression, StringPattern, StringReplacement) SQL Server/MySQL
REPLICATE MySQL REPLICATE(ColumnName, NumberOfTimes) REPEAT(column_name, number_of_times) SQL Server
REVERSE REVERSE(ColumnName) SQL Server/MySQL
STUFF / INSERT MySQL INSERT(column_name, start_index, length, insert_str) STUFF(ColumnName, StartIndex, Length, InsertStr) SQL Server
PI SQL Server/MySQL PI()
ABS SQL Server/MySQL ABS(Number)
FLOOR / CEILING FLOOR/CEILING(number) SQL Server/MySQL
POWER MySQL POWER(NumberToRaise, Power) POW(number_to_raise, power) SQL Server
Random RAND() RAND(Seed) SQL Server/MySQL
ROUND ROUND(Number, Precision) SQL Server/MySQL
SIGN SIGN(Number) SQL Server/MySQL
Square Root SQL Server/MySQL SQRT(Number)
Date Addition MySQL DATEADD( DatePart, Quantity, ColumnName) DATE_ADD( column_name, INTERVAL quantity date_part) SQL Server
Date Difference MySQL DATEDIFF( DatePart, FirstDate, SecondDate) DATEDIFF( first_date, second_date) SQL Server
Date Name MySQL DATENAME( DatePart, Date) DAYNAME(date) SQL Server
Day / Month / Year MySQL DAY / MONTH / YEAR(Date) DAY / DAYOFMONTH / DAYOFYEAR(date) SQL Server
Current Time MySQL GETDATE() NOW() SQL Server
Cast CAST (expression AS type) SQL Server/MySQL
Conversion MySQL CONVERT(expr, type) CONVERT(type, expr) SQL Server
Null Check MySQL ISNULL( CheckExpression, ReplacementValue) IFNULL( check_expression, replacement_value) SQL Server
Using LIKE syntax SELECTcolumn_name(s)FROMtable_nameWHEREcolumn_nameLIKEpattern;
Wildcards %- A substitute for zero or more characters _ - A substitute for a single character [charlist] –Sets and ranges of characters to match [^charlist] or [!charlist] – Matches only a character not in the brackets (Not working in MYSQL)
Summary There are a lot of built in functions that can help us make some programmable logic inside the database. There are some differences between the SQL Server and the MySQL functions, but almost all of themhave their equivalent in one way or another.
Built-in Functions https://softuni.bg/courses/
License This course (slides, examples, demos, videos, homework, etc.)is licensed under the "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International" license • Attribution: this work may contain portions from • "Databases" course by Telerik Academy under CC-BY-NC-SA license
Free Trainings @ Software University • Software University Foundation – softuni.org • Software University – High-Quality Education, Profession and Job for Software Developers • softuni.bg • Software University @ Facebook • facebook.com/SoftwareUniversity • Software University @ YouTube • youtube.com/SoftwareUniversity • Software University Forums – forum.softuni.bg