Mysql Fun
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Mysql Fun

  • 1,870 views
Uploaded on

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

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.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,870
On Slideshare
1,862
From Embeds
8
Number of Embeds
2

Actions

Shares
Downloads
50
Comments
0
Likes
1

Embeds 8

http://www.slideshare.net 7
http://blendedschools.blackboard.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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. * 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. * 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. * 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. * 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. 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. * 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. * 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. 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. * 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.
    • The Main Features of MySQL
    • Internals and Portability:
    • Written in C and C++.
    • Tested with a broad range of different compilers.
    • Cross-platform support
    • Triggers
    • Cursors
    • Data Types:
    • Many data types: signed/unsigned integers 1, 2, 3, 4, and 8 bytes long, FLOAT, DOUBLE,
    • CHAR, VARCHAR, BINARY, VARBINARY, TEXT, BLOB, DATE, TIME, DATETIME, TIMESTAMP, YEAR, SET, ENUM
    • True Varchar support
  • 12.
    • Statements and Functions:
    • Full operator and function support in the SELECT list and WHERE clause of queries.
    • Full support for SQL GROUP BY and ORDER BY clauses. Support for group functions (COUNT(), AVG(), STD(), SUM(), MAX(), MIN(), and GROUP_CONCAT()).
    • Support for LEFT OUTER JOIN and RIGHT OUTER JOIN with both standard SQL and ODBC syntax.
    • Support for aliases on tables and columns as required by standard SQL.
    • 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.
    • Security:
    • A privilege and password system that is very flexible and secure, and that allows host-based verification.
    • Password security by encryption of all password traffic when you connect to a server.
  • 13.
    • Scalability and Limits:
    • 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.
    • Connectivity:
    • Clients can connect to MySQL Server using several protocols:
    • Clients can connect using TCP/IP sockets on any platform.
    • MySQL client programs can be written in many languages. A client library written in C is available for clients written in C or C++.
    • APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl are available, allowing MySQL clients to be written in many languages
  • 14.
    • Storage Engines
    • MyISAM
    • The default MySQL storage engine and the one that is used the most in Web, data warehousing, and other application environments.
    • InnoDB
    • 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,
    • InnoDB also supports FOREIGN KEY referential-integrity constraints.
  • 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.