MYSQL
MySQL is an open-source relational database management system (RDBMS) that uses structured query language (SQL) for accessing and managing data. Developed by MySQL AB and now owned by Oracle Corporation, MySQL is widely used for web applications and is a central component of the LAMP stack (Linux, Apache, MySQL, PHP/Perl/Python). Known for its reliability, robustness, and ease of use, MySQL supports various storage engines and offers features like transactions, replication, and clustering, making it suitable for both small and large-scale applications.
MySQL Tutorial
A MySQL intro is an overview that introduces the basic concepts, features, and functionalities of the MySQL database management system.
MySQL RDBMS is an open-source relational database management system that uses SQL for managing and accessing data efficiently.
MySQL SQL
MySQL SQL refers to the structured query language used to manage and manipulate data within MySQL databases.
MySQL SELECT retrieves data from a database based on specified criteria, allowing for flexible querying of information.
MySQL WHERE specifies conditions that filter rows retrieved from a database, allowing for precise data selection based on specified criteria.
The AND and OR operators are used to filter records based on more than one condition
MySQL ORDER BY is a clause used to sort the result-set of a query in ascending or descending order based on specified columns or expressions.
MySQL INSERT INTO is a command used to add new records or rows into a specified table in a database.
MySQL NULL Values represent missing or undefined data in a database, indicating that a particular field does not contain any value.
MySQL UPDATE is a command used to modify existing records in a table by changing values in specified columns based on specified conditions in the WHERE clause.
MySQL DELETE is a command used to remove existing records from a table based on specified conditions in the WHERE clause.
MySQL LIMIT is a clause used to restrict the number of rows returned by a query, allowing you to specify the maximum number of records to retrieve.
MySQL MIN and MAX functions are used to find the smallest and largest values in a specified column, respectively.
MySQL COUNT(): Counts the number of rows that meet specific criteria.
MySQL AVG(): Computes the mean value of a specified column.
MySQL SUM(): Totals all the values in a specified column.
MySQL's LIKE
operator is used to search for a specified pattern in a column.
MySQL wildcards are symbols used in SQL queries with LIKE or NOT LIKE operators to match patterns within strings. They include % to match any sequence of characters (including zero), and _ to match any single character.
IN
in MySQL is an operator used in a WHERE
clause to specify multiple values for a column, allowing the selection of rows where the column value matches any of the specified values.
BETWEEN in MySQL is an operator used in a WHERE clause to filter data within a specified range of values, inclusive of both endpoints.
MySQL aliases are temporary names assigned to database tables or columns, allowing them to be referenced with shorter or more meaningful names in SQL queries.
MySQL joins are SQL operations used to combine rows from two or more tables based on related columns, enabling queries to retrieve data from multiple tables simultaneously.
MySQL INNER JOIN retrieves records with matching values in both tables based on a related column.
MySQL LEFT JOIN retrieves all records from the left table and matching records from the right table, if any, based on a related column.
MySQL RIGHT JOIN retrieves all records from the right table and the matched records from the left table, if any, based on a related column.
MySQL CROSS JOIN returns the Cartesian product of two tables, combining each row from the first table with every row from the second table.
MySQL Self Join is a join in which a table is joined with itself to combine rows that satisfy a given condition.
MySQL UNION combines the results of two or more SELECT statements into a single result set, eliminating duplicates by default.
MySQL GROUP BY is a clause used to aggregate identical data into groups based on one or more columns, often used with aggregate functions like SUM or COUNT.
MySQL HAVING is a clause used to filter group rows that meet specified conditions when GROUP BY is used.
MySQL EXISTS is a condition used to test whether a subquery returns any rows. If the subquery returns at least one row, the EXISTS condition evaluates to true; otherwise, it evaluates to false.
MySQL ANY and ALL are used with subqueries and compare a value to a set of values.
The INSERT INTO SELECT statement in MySQL inserts data into a table by selecting data from another table.
The CASE statement in MySQL is used for conditional logic to return different values based on specified conditions.
MySQL NULL functions are used to handle NULL values in queries and include functions like ISNULL, IFNULL, and COALESCE to manage and manipulate NULL values effectively.
MySQL comments are used to annotate SQL code for documentation purposes and can be single-line (using --
) or multi-line (enclosed between /* */
).
MySQL operators are symbols or keywords used to perform operations on values or expressions, such as arithmetic operations (+, -, *, /), comparison operations (>, <, =), logical operations (AND, OR, NOT), and more.
My SQL Database
MySQL CREATE
statement is used to create new databases, tables, indexes, views, or other database objects."
MySQL DROP is used to delete databases, tables, indexes, views, or other database objects.
MySQL CREATE TABLE is used to create a new table in a database, specifying its structure with columns, data types, and optional constraints.
MySQL DROP TABLE
is used to delete an existing table from a database.
MySQL ALTER TABLE is used to modify an existing table structure, such as adding or removing columns, modifying column data types, or adding constraints.
SQL constraints define rules that dictate the data within a table.
MySQL NOT NULL ensures that a column cannot contain NULL values.
MySQL UNIQUE ensures that all values in a column are distinct
MySQL PRIMARY KEY uniquely identifies each record in a table and ensures that the key does not contain NULL values.
MySQL FOREIGN KEY establishes a relationship between tables, enforcing referential integrity and preventing actions that would break links between related tables.
MySQL CHECK
ensures that values inserted into a column satisfy a specified condition.
MySQL DEFAULT sets a default value for a column when no explicit value is specified during an INSERT operation.
MySQL CREATE INDEX is used to create an index on a table, which enables fast retrieval of rows based on the indexed columns.
MySQL AUTO INCREMENT
automatically generates unique values for a column when new rows are inserted into a table.
MySQL Dates
are used to store date and time values in databases, supporting various formats and functions for manipulation and comparison.
MySQL Views
are virtual tables generated by a query, allowing users to access and manipulate data as if it were a regular table.
MySQL References
MySQL data types define the type of data that can be stored in a column of a MySQL database table.
MySQL functions are reusable sets of SQL statements that perform specific operations and return a single value.
ASCII (American Standard Code for Information Interchange) is a character encoding standard that represents text in computers and communication equipment, assigning numeric codes to each character, including letters, numbers, punctuation marks, and control characters.
CHAR_LENGTH is a function that returns the number of characters in a string, excluding any trailing spaces.
CHARACTER_LENGTH is a function that calculates the number of characters in a string.
CONCAT is a function used in SQL to combine two or more strings into a single string.
CONCAT_WS is a function used in SQL to combine multiple strings with a specified separator.
FIELD is a function in SQL that returns the position of a string within a set of strings, or 0 if the string is not found.
FIND_IN_SET is a function in SQL that returns the position of a string within a comma-separated list of strings, or 0 if the string is not found.
FORMAT is a function in SQL used to format numbers with commas and a specified number of decimal places.
INSERT is a SQL command used to add new rows of data into a database table.
INSTR is a function used in programming languages like Visual Basic and VBA to search for the occurrence of one string within another, returning the position of the first occurrence or zero if not found.
LCASE is a function used in programming languages like Visual Basic and VBA to convert a string to lowercase letters.
LEFT is a function in programming languages like Excel and SQL used to extract a specified number of characters from the left side of a string.
LENGTH is a function used in programming languages such as SQL and JavaScript to determine the number of characters in a string or the number of elements in an array.
LOCATE is a function used in SQL to find the position of a substring within a string and returns the position of its first occurrence.
LOWER is a function in SQL used to convert all characters in a string to lowercase.
LPAD is a function used in SQL to pad a string with specified characters on the left side until it reaches a desired length.
LTRIM is a function in SQL used to remove leading spaces (spaces at the beginning) from a string.
MID is a function used in some programming languages to extract a substring from a string, starting at a specified position and extending for a certain number of characters.
POSITION is a function used in SQL to find the position of a substring within a string and returns the position of its first occurrence.
REPEAT is a function used in SQL to replicate a string a specified number of times.
REPLACE is a function used in SQL to replace all occurrences of a specified substring within a string with another substring.
REVERSE is a function used in SQL to reverse the characters in a string.
RIGHT is a function used in SQL to extract a specified number of characters from the right side of a string.
RPAD is a function used in SQL to pad a string with specified characters on the right side until it reaches a desired length.
RTRIM is a function used in SQL to remove trailing spaces (spaces at the end) from a string.
SPACE is a function used in SQL to generate a string consisting of a specified number of spaces.
STRCMP is a function that compares two strings and returns an integer value indicating their relative order.
SUBSTR is a function that extracts a portion of a string, specified by a starting position and length, and returns it as a new string.
SUBSTRING is a function that extracts a portion of a string based on specified starting position and length parameters.
SUBSTRING_INDEX is a function that extracts a substring from a string before a specified delimiter, with an option to specify which occurrence of the delimiter to use.
TRIM is a function that removes leading and trailing spaces from a string.
UCASE is a function that converts all characters in a string to uppercase.
UPPER is a function that converts all characters in a string to uppercase.
ABS is a function that returns the absolute value of a number, removing its sign.
ACOS is a function that returns the arccosine (inverse cosine) of a value, measured in radians, within the range [0, π].
ASIN is a function that returns the arcsine (inverse sine) of a value, measured in radians, within the range [-π/2, π/2].
ATAN is a function that returns the arctangent (inverse tangent) of a value, measured in radians, within the range [-π/2, π/2].
ATAN2 is a mathematical function that computes the arctangent of the quotient of its two arguments, ensuring correct quadrant placement.
AVG computes the arithmetic mean of a set of values, commonly used in statistical analysis to determine a central tendency.
CEIL rounds a numeric value up to the nearest integer, and returns the result.
CEILING rounds a numeric value up to the nearest integer, and returns the result.
COS is a mathematical function that calculates the cosine of a given angle in radians.
COT calculates the cotangent of an angle in radians, defined as the reciprocal of the tangent of an angle.
COUNT is a function used to determine the number of non-null values in a set of values or records.
DEGREES is a mathematical function that converts an angle measured in radians to its equivalent in degrees.
DIV is an arithmetic operator used for integer division, returning the quotient without the remainder.
EXP is a mathematical function that returns the value of Euler's number (approximately 2.71828) raised to the power of a given number.
FLOOR is a mathematical function that rounds a numeric value down to the nearest integer, and returns the result.
GREATEST is a function that returns the largest value among a list of expressions.
LEAST is a function that returns the smallest value from a list of arguments.
LN stands for "Logarithm Natural," a mathematical function representing the exponent to which the base number (usually Euler's number, e ≈ 2.718) must be raised to produce a given number.
The LOG function calculates the logarithm of a number with a specified base.
LOG10 is a mathematical function that computes the base-10 logarithm of a given number.
LOG2 is a mathematical function that computes the base-2 logarithm of a given number.
MAX is a function used to determine the highest value among a set of numbers or expressions.
MIN is a function used to determine the lowest value among a set of numbers or expressions.
MOD is a mathematical function that computes the remainder when one number is divided by another.
PI is a mathematical constant representing the ratio of a circle's circumference to its diameter, approximately equal to 3.14159.
POW is a mathematical function used to calculate a number raised to the power of another number.
In SQL, the POWER
function returns the result of raising a number to a specified exponent.
SQL radians function converts an angle in degrees to radians.
SQL RAND() function generates a random number.
SQL ROUND() function returns a number rounded to a specified number of decimal places.
SQL SIGN() function returns the sign of a number.
SQL SIN() function calculates the sine of an angle in radians.
SQL SQRT is a mathematical function used to calculate the square root of a numeric value in a SQL query.
SQL SUM is an aggregate function used to calculate the total sum of numeric values in a specified column or expression within a SQL query.
SQL TAN is a trigonometric function used to calculate the tangent of an angle in a SQL query.
SQL TRUNCATE is a command used to remove all records from a table in a database, effectively resetting it while preserving its structure.
SQL ADDDATE is a function that adds a specified number of days to a date, returning a new date value.
SQL ADDTIME is a function used to add a specified time interval to a given time or datetime value.
SQL CURDATE is a function that returns the current date in the system's timezone.
SQL CURRENT_DATE is a function that returns the current date in the system's timezone.
SQL CURRENT_TIME is a function that returns the current time in the system's timezone.
CURRENT_TIMESTAMP
in SQL returns the current date and time of the database server.
CURTIME()
in SQL returns the current time from the database server.
In SQL, DATE
represents a data type for storing dates without any associated time information.
DATEDIFF in SQL calculates the difference in days between two dates.
DATE_ADD in SQL is a function used to add a specified time interval to a date.
DATE_FORMAT in SQL is a function used to format date and time values based on a specified format string.
DATE_SUB is a function in SQL used to subtract a specified time interval from a date.
In SQL, DAY is a function used to extract the day of the month from a given date.
In SQL, DAYNAME is a function used to retrieve the name of the day of the week from a given date.
DAYOFMONTH is a function in SQL used to extract the day of the month from a given date.
DAYOFWEEK is a function in SQL used to extract the day of the week from a given date.
DAYOFYEAR is an SQL function used to extract the day of the year from a given date.
EXTRACT is a SQL function used to retrieve a specific part (e.g., year, month, day) from a date or timestamp.
FROM_DAYS is a function in MySQL that converts a day number into a date.
HOUR is a SQL function used to extract the hour portion from a given time or timestamp.
LAST_DAY in SQL returns the last day of the month for a given date.
LOCALTIME
in SQL returns the current date and time for the local time zone.
LOCALTIMESTAMP in SQL retrieves the current date and time including fractional seconds, based on the local time zone.
MAKEDATE in SQL is used to construct a date from year and day of year values.
MAKETIME in SQL is used to construct a time value from hour, minute, and second components.
MICROSECOND in SQL is a function that retrieves the microsecond part of a given time or datetime value.
MINUTE in SQL retrieves the minute component of a given time or datetime value.
MONTH in SQL retrieves the month component of a given date or datetime value.
MONTHNAME in SQL is a function that retrieves the name of the month from a given date or datetime value.
NOW in SQL retrieves the current date and time.
PERIOD_ADD in SQL is a function used to add a number of months to a period in the format YYYYMM.
PERIOD_DIFF in SQL calculates the difference in months between two periods in the format YYYYMM.
QUARTER in SQL is a function that returns the quarter of the year (1 to 4) for a given date.
SECOND in SQL retrieves the second component of a given time or datetime value.
SEC_TO_TIME in SQL converts a number of seconds into a time format (HH:MM).
STR_TO_DATE in SQL converts a string representation of a date and time into a proper datetime value using a specified format.
SUBDATE is a MySQL function that subtracts a specified number of days, months, or years from a given date, producing a new date.
SUBTIME is a MySQL function that subtracts a specified time interval from a given time or datetime value.
SYSDATE is a function in databases like Oracle and MySQL that returns the current date and time from the system's clock.
TIME refers to the representation of the current time or a specific time of day in a given context, typically as a part of a date-time format.
TIME_FORMAT is a function in MySQL that converts a time value to a specified format.
TIME_TO_SEC is a MySQL function that converts a time value into seconds.
TIMEDIFF is a MySQL function that calculates the difference between two time or datetime values.
TIMESTAMP is a data type in SQL that stores both date and time values.
TO_DAYS is a function in MySQL that converts a date or datetime value to a numeric value representing days since year 0.
WEEK is a function in SQL that returns the week number of a given date.
WEEKDAY is a function in SQL that returns the index of the weekday for a given date (0 = Monday, 6 = Sunday).
WEEKOFYEAR is a function in SQL that returns the week number within a year for a given date.
YEAR is a function in SQL that extracts the year from a date or datetime value.
YEARWEEK is a function in SQL that returns the year and week number concatenated together for a given date.
BIN is a MySQL function that converts a decimal number to its binary representation.
BINARY
is a keyword in SQL used to specify a binary string literal or to cast a string to a binary type.
CASE is a conditional expression in SQL used to evaluate multiple conditions and return a result based on them.
CAST
is a SQL function used to convert a value from one data type to another.
COALESCE returns the first non-null value in a list of expressions.
CONNECTION_ID returns the ID of the current client connection in a database session.
CONV() converts a number from one numeric base to another.
CONVERT function changes a value from one data type to another in SQL.
CURRENT_USER returns the username of the current database user.
DATABASE retrieves the name of the current database in use.
IF is a control flow function that returns one value if a condition is true and another value if the condition is false.
In SQL, IFNULL is a function that returns a specified value if the given expression is NULL; otherwise, it returns the expression itself.
In SQL, ISNULL
is a function that replaces NULL with a specified value.
LAST_INSERT_ID() is a function in SQL that returns the ID generated for the last AUTO_INCREMENT column in the current session.
SESSION_USER is a SQL function that returns the name of the current database user for the session.
SYSTEM_USER is a SQL function that returns the login name of the current user in the database system.
USER is a SQL function that returns the current user name in the context of the database system.
VERSION
is a SQL function that retrieves the version of the database system.