Mysql Fun


Published on

Here is the list of all important MySQL functions. Each function has been explained along with suitable example.


MySQL Group By Clause - The MySQL GROUP BY statement is used along with the SQL aggregate functions like SUM to provide means of grouping the result dataset by certain database table column(s).

MySQL IN Clause - This is a clause which can be used alongwith any MySQL query to specify a condition.

MySQL BETWEEN Clause - This is a clause which can be used alongwith any MySQL query to specify a condition.

MySQL UNION Keyword - Use a UNION operation to combine multiple result sets into one.

MySQL COUNT Function - The MySQL COUNT aggregate function is used to count the number of rows in a database table.

MySQL MAX Function - The MySQL MAX aggregate function allows us to select the highest (maximum) value for a certain column.

MySQL MIN Function - The MySQL MIN aggregate function allows us to select the lowest (minimum) value for a certain column.

MySQL AVG Function - The MySQL AVG aggregate function selects the average value for certain table column.

MySQL SUM Function - The MySQL SUM aggregate function allows selecting the total for a numeric column.

MySQL SQRT Functions - This is used to generate a square root of a given number.

MySQL RAND Function - This is used to generate a random number using MySQL command.

MySQL CONCAT Function - This is used to concatenate any string inside any MySQL command.

MySQL DATE and Time Functions - Complete list of MySQL Date and Time related functions.

MySQL Numeric Functions - Complete list of MySQL functions required to manipulate numbers in MySQL.

MySQL String Functions - Complete list of MySQL functions required to manipulate strings in MySQL.

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Mysql Fun

  1. 1. * ABS(X) Returns the absolute value of X. Mathematical Functions SELECT ABS(-32); 32 * CEIL(X) CEIL() is a synonym for CEILING(). SELECT CEILING(1.23); 2
  2. 2. * MOD() also works on values that have a fractional part and returns the exact remainder after division: SELECT MOD(34.5,3); 1.5 * PI() Returns the value of π (pi). SELECT PI(); 3.141593
  3. 3. * POW(X,Y) Returns the value of X raised to the power of Y. SELECT POW(2,2); 4 * SQRT(X) Returns the square root of a nonnegative number X. SELECT SQRT(4); 2
  4. 4. * FLOOR(X) Returns the largest integer value not greater than X. SELECT FLOOR(1.23); 1 * POWER(X,Y) This is a synonym for POW().
  5. 5. * COT(X) Returns the cotangent of X. SELECT COT(12); -1.5726734063977 * COS(X) Returns the cosine of X, where X is given in radians. SELECT COS(PI()); -1
  6. 6. ADDDATE(date,INTERVAL expr unit), ADDDATE(expr,days) When invoked with the INTERVAL form of the second argument, ADDDATE() is a synonym for DATE_ADD(). The related function SUBDATE() is a synonym for DATE_SUB(). For information on the INTERVAL unit argument, see the discussion for DATE_ADD(). SELECT DATE_ADD('2008-01-02', INTERVAL 31 DAY); '2008-02-02' SELECT ADDDATE('2008-01-02', INTERVAL 31 DAY); '2008-02-02' Date and Time Functions
  7. 7. * CURDATE() Returns the current date as a value in 'YYYY-MM-DD' SELECT CURDATE(); '2008-06-13' * CURTIME() Returns the current time as a value in 'HH:MM:SS' SELECT CURTIME(); '23:50:26'
  8. 8. * DATEDIFF(expr1,expr2) DATEDIFF() returns expr1 – expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation. SELECT DATEDIFF('2007-12-31 23:59:59','2007-12-30'); 1
  9. 9. NOW() Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' SELECT NOW(); '2007-12-15 23:50:26' SECOND(time) Returns the second for time, in the range 0 to 59. SELECT SECOND('10:05:03');
  10. 10. * YEAR(date) Returns the year for date, in the range 1000 to 9999, or 0 for the “zero” date. SELECT YEAR('1987-01-01'); 1987 * MINUTE(time) Returns the minute for time, in the range 0 to 59. SELECT MINUTE('2008-02-03 10:05:03'); 5
  11. 11. <ul><li>The Main Features of MySQL </li></ul><ul><li>Internals and Portability: </li></ul><ul><li>Written in C and C++. </li></ul><ul><li>Tested with a broad range of different compilers. </li></ul><ul><li>Cross-platform support </li></ul><ul><li>Triggers </li></ul><ul><li>Cursors </li></ul><ul><li>Data Types: </li></ul><ul><li>Many data types: signed/unsigned integers 1, 2, 3, 4, and 8 bytes long, FLOAT, DOUBLE, </li></ul><ul><li>CHAR, VARCHAR, BINARY, VARBINARY, TEXT, BLOB, DATE, TIME, DATETIME, TIMESTAMP, YEAR, SET, ENUM </li></ul><ul><li>True Varchar support </li></ul>
  12. 12. <ul><li>Statements and Functions: </li></ul><ul><li>Full operator and function support in the SELECT list and WHERE clause of queries. </li></ul><ul><li>Full support for SQL GROUP BY and ORDER BY clauses. Support for group functions (COUNT(), AVG(), STD(), SUM(), MAX(), MIN(), and GROUP_CONCAT()). </li></ul><ul><li>Support for LEFT OUTER JOIN and RIGHT OUTER JOIN with both standard SQL and ODBC syntax. </li></ul><ul><li>Support for aliases on tables and columns as required by standard SQL. </li></ul><ul><li>Support for DELETE, INSERT, REPLACE, and UPDATE to return the number of rows that were changed (affected), or to return the number of rows matched instead by setting a flag when connecting to the server. </li></ul><ul><li>Security: </li></ul><ul><li>A privilege and password system that is very flexible and secure, and that allows host-based verification. </li></ul><ul><li>Password security by encryption of all password traffic when you connect to a server. </li></ul>
  13. 13. <ul><li>Scalability and Limits: </li></ul><ul><li>Support for large databases. We use MySQL Server with databases that contain 50 million records. We also know of users who use MySQL Server with 200,000 tables and about 5,000,000,000 rows. </li></ul><ul><li>Connectivity: </li></ul><ul><li>Clients can connect to MySQL Server using several protocols: </li></ul><ul><li>Clients can connect using TCP/IP sockets on any platform. </li></ul><ul><li>MySQL client programs can be written in many languages. A client library written in C is available for clients written in C or C++. </li></ul><ul><li>APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl are available, allowing MySQL clients to be written in many languages </li></ul>
  14. 14. <ul><li>Storage Engines </li></ul><ul><li>MyISAM </li></ul><ul><li>The default MySQL storage engine and the one that is used the most in Web, data warehousing, and other application environments. </li></ul><ul><li>InnoDB </li></ul><ul><li>A transaction-safe storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data. InnoDB row-level locking (without escalation to coarser granularity locks) and Oracle-style consistent nonlocking reads increase multi-user concurrency and performance. InnoDB stores user data in clustered indexes to reduce I/O for common queries based on primary keys. To maintain data integrity, </li></ul><ul><li>InnoDB also supports FOREIGN KEY referential-integrity constraints. </li></ul>
  15. 15. Memory Stores all data in RAM for extremely fast access in environments that require quick lookups of reference and other like data. CSV The CSV storage engine stores data in text files using comma-separated values format.You can use the CSV engine to easily exchange data between other software and applications that can import and export in CSV format. Blackhole The Blackhole storage engine accepts but does not store data and retrievals always return an empty set. The functionality can be used in distributed database design where data is automatically replicated, but not stored locally.