SQL / MySQL examples (example source code) Organized by topic

Procedure Function /

Begin End 1BIGINT 2
Buildin Functions 6Call 6
CASE 5CHAR 1
Condition HANDLER 10Create Table 3
CSharp 2DATE 3
DATETIME 1Default 2
DEFINER 1Delete 2
Delimiter 1DETERMINISTIC 1
DOUBLE 1Drop Table 1
Dynamic Statement 2FLOAT 2
Function Data Dictionary 3Function Returning 7
Function 10IF statement 5
Insert 4INT 1
Introduction 8ITERATE 1
Java 2LEAVE 3
Lock 1LOOP 6
NUMERIC 2Operator 2
Output 3Parameters 15
Perl 2PHP 2
Predefined Exceptions 3Procedure Data Dictionary 5
Procedure 14Python 1
Recursion 1Repeat until 4
Select Into 3Set 4
TEXT 2Transaction 7
Update Table 2VARCHAR 2
Variable Assignment 3Variable Declaration 3
Variable Scope 5VB.net 1
While 4

Trigger /

After Trigger 3Before Trigger 7
Drop Trigger 1NEW 4
Trigger Data Dictionary 1

View /

Alter View 2Check 3
Create View 17Drop View 1
Explain View 1Nested View 1
Updatable View 1View Structure 2

Cursor /

Close 1Declare 3
Fetch 8Handler 1
Open 1

Select Clause /

Alias 7All 8
Any 7Count 14
Distinct 16Exists 7
Function In Select 1Group 45
HAVING 7In 14
Like 11Limits 27
Operator 14ROLLUP 4
Row 6Select 13
Simple Select 13Sort Order 69
Sub query 68Union 31
Unique 3Using 2
Variable 50

Where Clause /

And 12OR 6
Where 30

Insert Delete Update /

Delete 14Insert 24
Update 25

Flow Control /

CASE WHEN Select 6Flow Control Select 1
IF 2

Data Type /

AUTO_INCREMENT 19BigInt 1
Bit 1Blob 3
Boolean 3Char 13
Data Type Convert 1Data Type Summary 5
Date 10DateTime 5
Decimal 9Double 2
ENUM 30Float 5
FullText 1Int 7
Integer Type 9LongBlob 1
LongText 1MediumBlob 1
MediumInt 1MediumText 1
Null 22Serial 1
Set 6Small Int 7
Text Type 3Time 3
TimeStamp 13Tiny Int 4
TinyBlob 1TinyText 1
Varchar 7Year 1

Date Time /

ADDDATE 7ADDTIME 3
CURDATE 4CURTIME 2
Date Compare Order 6Date Format 29
Date Function 11Date Time Function 1
Date Type 13DATE 7
DATEDIFF 2DATETIME 3
DATE_ADD 9DATE_FORMAT 2
DATE_SUB 6Day 3
DAYNAME 8DAYOFMONTH 2
DAYOFWEEK 5DAYOFYEAR 3
EXTRACT 1FROM_DAYS 2
FROM_UNIXTIME 3GET_FORMAT 1
HOUR 2INTERVAL 14
MINUTE 1Month 10
MONTHNAME 2NOW 2
SECOND 2SEC_TO_TIME 4
SUBDATE 2Time zone 6
Time 8TIMEDIFF 2
TIMESTAMP 7TIMESTAMPADD 1
TIMESTAMPDIFF 1TIME_FORMAT 3
TIME_TO_SEC 9TO_DAYS 6
UNIX_TIMESTAMP 5UTC_TIMESTAMP 1
WEEKDAY 2Year 38

String /

ASCII 3Binary 11
CHAR_LENGTH 2COLLATION 1
CONCAT 12CONCAT_WS 3
CONVERT 3Escape 2
INSTR 1LEFT 4
LENGTH 9LOCATE 4
LOWER 2Mid 2
ORD 1REPEAT 2
REPLACE 2REVERSE 1
RIGHT 4Row 3
RPAD 1SOUNDEX 1
STRCMP 2String Append 6
String Case Function 1String Compare 8
String Function 2String Length 1
String Type 3Sub String 2
SUBSTRING 10SUBSTRING_INDEX 3
Trim 3UPPER 1

Math /

ABS 2ACOS 1
ASIN 1ATAN 2
Average 4CEIL 1
COS 1COT 3
Degree 1Exp 1
Floor Ceiling 2FLOOR 5
GREATEST 1LEAST 1
LOG 2LPAD 1
Max Min 1Max 3
MID 1Min 1
MOD 5PI 2
PLUS 1Power 3
RADIANS 1Random 1
Round 3SIN 2
SQRT 2Sum 8
TAN 1TRUNCATE 2

Function /

AND 2Between 7
BIN 2BINARY 1
BIT Count 1Bit 13
BIT_AND 1BIT_OR 1
BIT_XOR 2CASE 21
CAST 8COALESCE 3
COERCIBILITY 1Compare Function 1
CONNECTION_ID 1CONV 2
COT 1DECODE 1
Define Function 4EXTRACT 1
FIELD 1FOUND_ROWS 2
Function In Join 2Function In Select 2
IF 6IFNULL 7
IN 4INET_ATON 3
INSTR 1ISNULL 1
LAST_INSERT_ID 6MD5 4
MySQL Version 1NULLIF 1
OR 2RAND 12
Replace 7Right 1
SHA 1SIGN 1
XOR 2

Aggregate Functions /

AVG 8COUNT 31
GROUP_CONCAT 3MAX 10
MIN 9STD 1
STDDEV 1STDDEV_SAMP 1
SUM 11VARIANCE 1
VAR_SAMP 1

Geometric /

AREA 3ASTEXT 3
Bounding Box 1Distance 2
ENDPOINT 1ENVELOPE 1
Geometric Functions 2Geometric Objects 1
Geometric Types 2GeometryCollection 2
GEOMFROMTEXT 3Index 2
Length 3Line 1
MULTIPOINT 1Point 3
polygon 4TOUCHES 1
X 1Y 1

XML /

Descendant 1Element 8
EXTRACTVALUE 13Update 1
UPDATEXML 1XPath 1

Regular Expression /

Begin With 10Class 1
Contains 10End With 5
Introduction 23Like 17
Patterns 10Percentage wildcard 4
REGEXP 21Underscore 1

I18N /

CHARSET 21Collate 22
utf8 5

FullText Search /

Boolean Search 9Index 6
MATCH 16Natural Language 3
Operator 3Word 15

Database /

Create Database 2Current Database 3

Event /

Alter 1Create 10
Drop 1Enable 1
Rename 1Schedule 6

Backup Load /

Backup 1Batch 1
Dump 1Export 3
Load Data Into Table 13Load Text File 2
Save To Text File 18

Command MySQL /

ANALYZE 1BACKUP 2
Cancel 1CHECK 2
CHECKSUM 1Clear 1
Comment 3Connect MySQL 1
Database 1DEALLOCATE 1
DESCRIBE 3Drop 2
Exit MySQL 1EXPLAIN 3
Global Variables 10INFORMATION_SCHEMA 9
LOAD 15Lock 1
Matadata 8my.cnf 3
MySQL 43Mysqladmin 10
mysqldump 26mysqlhotcopy 1
mysqlimport 5OPTIMIZE 3
PREPARE 3RENAME 7
Repair 2RESTORE 1
Set 1Show 41
SOURCE 1Status 1
Version 3

User Permission /

Add User 5Drop User 3
Grant 53Password 33
Permission 3Privilege 1
Rename User 1REVOKE 7
SQL Privilege 11User Create 2
User Table 8USER 10

Table Index /

Alter Table 44Backup Table 6
Check 3Column 77
Constraint 4Copy Table 17
Create Table 32Current Table 1
Default Value 5Delete Table 3
Drop Table 5Index 39
Rename Table 1Table Structure 1
Temporary Table 9TRUNCATE 3

Join /

Condition JOIN 1Cross Join 1
Database Join 4Delete From Join 3
Full Join 3Function In Join 2
Inner Join 10Join Delete 3
Join Order 3Join Select 39
Join Table 7Join Three Tables 2
Join Update 2Left Join 22
Right Join 5Self Join 4
Simple JOIN 20Using 9

Transaction /

autocommit 4COMMIT 2
ISOLATION 2Lock 5
RollBack 4Savepoint 2
TRANSACTION COMMIT 2TRANSACTION ROLLBACK 3

Key /

Foreign Key 9Key 1
Primary Key 19

Engine /

Change 2CSV 1
Engine Type 3InnoDB 1
Merge 1MyISAM 6