MySQL SQL Reference |
|
In the following commands and functions, any italicized text should be replaced by a variable or name of your choice. Any text within brackets ( [ and ] ) is optional. This is only a short reference of the SQL commands supported in MySQL. It is NOT the full list and also may not be complete nor up-to-date. |
Commands
CREATE DATABASE [IF NOT EXISTS] name CREATE [UNIQUE|FULLTEXT] INDEX name ON table (column,..) CREATE TABLE [IF NOT EXISTS] name DELETE FROM table [WHERE clause] [LIMIT n] DROP DATABASE [IF EXISTS] name DROP TABLE [IF EXISTS] name GRANT privilege ON table TO user INSERT [INTO] table [ (column, ...) ] VALUES (values, ...) LOAD DATA INFILE file INTO TABLE name SELECT [DISTINCT|ALL| |] FROM table [WHERE clause ] UPDATE table SET column=value,... [WHERE clause] [LIMIT n] Logical Operators NOT or ! - performs a logical not OR or | | - performs a logical or XOR - performs a logical exclusive or AND or && - performs a logical and |
Aggregate Functions
AVG(expression) BIT_AND(expression) BIT_OR(expression) COUNT(expression) MAX(expression) MIN(expression) STD(expression)/STDDEV(expression) SUM(expression) General Functions ABS(number) ACOS(number) ADDDATE(date, INTERVAL, amount, type) ASCII(char) ASIN(number) ATAN(number) ATAN2(x, y) BENCHMARK(num, function) BIN((decimal) BIT_COUNT(number) BIT_LENGTH(number) CEILING(number) CHAR_LENGTH(string) COS(radians) COT(radians) CURDATE() CURTIME() DATABASE() DATE_FORMAT(date, format) DAYNAME(date) DAYOFMONTH(date) DAYOFWEEK(date) DAYOFYEAR(date) EXP(power) FLOOR(number) FORMAT(number, decimals) HOUR(time) LENGTH(string) LOG(number) LOWER(number) MD5(string) MINUTE(time) MONTH(date) MONTHNAME(date) NOW() PASSWORD(string) QUARTER(date) REVERSE(string) SECOND(time) SIGN(number) SPACE(number) SQRT(number) UPPER(string) VERSION() WEEK(date) WEEKDAY(date) YEAR(date) |