SQL

Published on 29 Aug 2014
Cheat Sheet / Transcript is Here : http://goo.gl/Z1p50M
Best MySQL Book : http://goo.gl/zJC254
Welcome to my MySQL video tutorial. I’ll cover 95 – 98% of everything you’ll ever need to know in one video.
I cover creating / destroying databases, creating / destroying tables, data types, NULL, DEFAULT, ENUM, AUTO_INCREMENT, primary keys, foreign keys, atomic data, normalized, DESCRIBE, INSERT, ALTER, SELECT, SHOW, RENAME, WHERE, logical operators, comparison operators, ORDER BY, GROUP BY, LIMIT, string operators, joins, LIKE, DISTINCT, math functions and more.

The world’s most popular open source database

The software’s official homepage with news, downloads and documentation.

Why MySQL?
Many of the world’s largest and fastest-growing organizations including Facebook, Google, Adobe, Alcatel Lucent and Zappos rely on MySQL to save time and money powering their high-volume Web sites, business-critical systems and packaged software.


MySQL
(https://en.wikipedia.org/wiki/MySQL)

MySQL is an open-source relational database management system (RDBMS). In July 2013, it was the world’s second most widely used RDBMS, and the most widely used open-source client–server model RDBMS. It is named after Michael Widenius’ (who is a co-founder of MySQL) daughter, My, while “SQL” stands as the abbreviation for Structured Query Language. The MySQL development project has made its source code available under the terms of the GNU General Public License, as well as under a variety of proprietary agreements. MySQL was owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned by Oracle Corporation. For proprietary use, several paid editions are available, and offer additional functionality.

MySQL is a popular choice of database for use in web applications, and is a central component of the widely used LAMP open-source web application software stack (and other “AMP” stacks). LAMP is an acronym for “Linux, Apache, MySQL, Perl/PHP/Python”. Free-software open-source projects that require a full-featured database management system often use MySQL. Applications that use the MySQL database include: TYPO3, MODx, Joomla, WordPress, phpBB, MyBB, Drupal and other software. MySQL is also used in many high-profile, large-scale websites, including Google (though not for searches), Facebook, Twitter, Flickr, and YouTube.

On all platforms except Windows, MySQL ships with no GUI tools to administer MySQL databases or manage data contained within the databases. Users may use the included command line tools, or install MySQL Workbench via a separate download. Many third party GUI tools are also available.


MySQL | The Most Popular Open-Source Database | Oracle
(http://www.oracle.com/us/products/mysql/overview/index.html)

MySQL is the world’s most popular open source database, enabling the cost-effective delivery of reliable, high-performance and scalable Web-based and embedded database applications, including all five of the top five websites.

MySQL Editions
In addition to MySQL’s ease of use, high performance and reliability you can benefit from advanced features, management tools and technical support to develop, deploy and manage your MySQL applications.


MySQL :: MySQL 5.7 Reference Manual :: 4 Tutorial
(https://dev.mysql.com/doc/refman/5.7/en/tutorial.html)

Chapter 4 Tutorial

This chapter provides a tutorial introduction to MySQL by showing how to use the mysql client program to create and use a simple database. mysql (sometimes referred to as the terminal monitor or just monitor) is an interactive program that enables you to connect to a MySQL server, run queries, and view the results. mysql may also be used in batch mode: you place your queries in a file beforehand, then tell mysql to execute the contents of the file. Both ways of using mysql are covered here.


tutorialspointTutorialsPoint MySQL Tutorial
(http://www.tutorialspoint.com/mysql/)

Download PDF Version

MySQL is the most popular Open Source Relational SQL database management system. MySQL is one of the best RDBMS being used for developing web-based software applications.

This tutorial will give you quick start with MySQL and make you comfortable with MySQL programming.


MySQL TutorialMySQL Tutorial
(http://www.mysqltutorial.org/)

Welcome to the MySQL Tutorial website!
You will learn MySQL fast, easy and fun. This website provides you with a complete MySQL tutorial presented in an easy-to-follow manner. Each tutorial has practical examples with SQL script and screenshots available.

Are you new here? If so, first, you may want to find out what MySQL is. Then, you can install MySQL database server, download MySQL sample database and load the sample database into your own local MySQL database server to get started with MySQL quickly.

MySQL Tutorial for Developers

Are you a web developer looking for learning MySQL fast?

In this section, you will be getting started with MySQL right away. You will learn how to use MySQL effectively to get your work done more productively.

If you go through the entire tutorials, you will know how to manage MySQL databases and manipulate data using various techniques such as SQL queries, MySQL stored procedures, database views, triggers, etc.

  • Basic MySQL TutorialBasic MySQL Tutorial
    This section helps you get familiar with basic MySQL including managing MySQL database and manipulating data using various SQL statements such as INSERT, DELETE, UPDATE and SELECT. You will also learn about advanced data selection techniques including INNER JOIN, LEFT JOIN, Subquery, UNION, etc.
  • MySQL Tips
    We provide you with the advanced MySQL techniques and tips to help you solve the most difficult challenges in MySQL effectively.

 

  • MySQL Stored ProcedureMySQL Stored Procedure
    In this section, you will learn how to create stored procedure in MySQL with clear explanation and practical examples.

  • MySQL TriggersMySQL Triggers
    MySQL triggers are stored programs that are executed automatically to respond to specific events associated with table e.g., insert, update or delete a record. This section shows you how to work with MySQL database triggers.

  • MySQL ViewsMySQL Views
    In this section, you will learn what a database view is, how to create a database view and manage it in MySQL.

  • MySQL Full-Text SearchMySQL Full-Text Search
    In this section, we show you how to use MySQL full-text search with various full-text searching techniques such as natural language search, Boolean language search and query expansion

.

  • MySQL FunctionsMySQL Functions
    This section gives you the most commonly used MySQL functions including aggregate functions, string functions, date and time functions, and control flow functions.

MySQL Tutorial for Database Administrators

This step-by-step tutorial gives you in-depth background information on MySQL administration.

We cover everything from basic to advanced MySQL administration and configuration. All MySQL administration tutorials presented in this section are practical and widely used in enterprise environments.

  • MySQL AdministrationMySQL Administration
    In this section, you will find a lot of useful MySQL administration tutorials including MySQL server start-up and shutdown, MySQL server security, MySQL database maintenance, backup and replication.

MySQL Programming Interfaces

In this section, we will show you how to write MySQL-based applications for accessing MySQL databases.

  • Python MySQL TutorialPython MySQL Tutorial
    This Python MySQL tutorial section shows you how to use MySQL connector/Python to access MySQL databases.

  • PHP MySQL TutorialPHP MySQL Tutorial
    You will learn how to interact with MySQL using PHP Data Objects or PDO, which provides a lightweight and consistent interface for accessing MySQL Database.

  • Perl MySQL TutorialPerl MySQL Tutorial
    This Perl MySQL section shows you how to interact with MySQL by using Perl DBI API for connecting to and disconnecting from MySQL databases, creating tables, handling data, and managing transactions.

  • MySQL JDBC TutorialMySQL JDBC Tutorial
    Java JDBC API provides a standard interface to interact with any relational databases. In this MySQL JDBC tutorial section, we will show you how to use JDBC to interact with MySQL databases.

MySQL Tutorial References

If you need more information on MySQL, check it out the MySQL resources.


Basic MySQL TutorialBasic MySQL Tutorial
(http://www.mysqltutorial.org/basic-mysql-tutorial.aspx)

Download MySQL Sample Database (classicmodels)

Download MySQL Sample Database Schema (classicmodels)

The MySQL sample database schema consists of the following tables:

  • Customers: stores customer’s data.
  • Products: stores a list of scale model cars.
  • ProductLines: stores a list of product line categories.
  • Orders: stores  sales orders placed by customers.
  • OrderDetails: stores sales order line items for each sales order.
  • Payments: stores payments made by customers based on their accounts.
  • Employees: stores all employee information as well as the organization structure such as who reports to whom.
  • Offices: stores sales office data.

MySQL Sample Database Schema

This basic MySQL tutorial section explains some of the basic SQL statements. If this is the first time you have used a database, this section gives you the basic information you need to interact with MySQL database server such as managing databases, creating tables, and querying data. Alternatively, if you’re already familiar with other RDBMS such as PostgreSQL, Oracle, or Microsoft SQL Server, you can use this section to refresh your knowledge and also understand how SQL dialect of MySQL is different from other database management systems.

Getting started with MySQL

This section helps you get started with MySQL. We will start installing MySQL, downloading a sample database, and loading data into the MySQL server for practicing.

Querying data from MySQL database

This section helps you learn how to query data from the MySQL database sever. We will start with a simple SELECT statement that allows you to query data from a single table. And then we will demonstrate some advanced techniques to query data from multiple tables such as join and union.

Modifying data in MySQL

In this section, you will learn how to insert, update, and delete data from tables using various MySQL statements.

Working with MySQL databases, tables, and indexes

This section shows you how to manage the most important database objects in MySQL including database, tables, and indexes. Note that we have specific sections for stored procedures, triggers, and views.

  • Managing database in MySQL – you will learn various statements to manage MySQL databases including creating a new database, removing an existing database, selecting a database, and listing all databases.
  • Understanding MySQL Table Types – it is essential to understand the features of each table type so that you can use them effectively to maximize the performance of your databases.
  • MySQL data types – shows you various MySQL data types so that you can apply them effectively in designing database tables.
  • MySQL INT – shows you how to use integer data type. We also show you how to use ZEROFILL and display width attributes of the integer column.
  • MySQL DECIMAL – shows you how to use DECIMAL data type to store exact values in decimal format.
  • MySQL DATE – introduces you to the DATE data type and show you some date functions to handle the date data effectively.
  • MySQL TIME – walks you through the features of TIME data type and shows you how to use some useful temporal functions to handle time data.
  • MySQL DATETIME – introduces you to the DATETIME data type and some useful functions to manipulate DATETIME values.
  • MySQL TIMESTAMP – introduces you to TIMESTAMP and its features called automatic initialization and automatic update that allow you to define auto-initialized and auto-updated columns for a table.
  • Creating tables using MySQL CREATE TABLE statement – shows you how to create a new tables in a database using CREATE TABLE statement.
  • MySQL sequence – shows you how to use sequence to generate unique numbers automatically for the primary key column of a table.
  • MySQL primary key  – you will learn how to use primary key constraint to create the primary key for the table.
  • MySQL foreign key – introduces you to foreign key and shows you step by step how to create and drop foreign keys.
  • Using MySQL ALTER TABLE to change table structure – you will learn about the ALTER TABLE statement that changes existing table structure such as adding or removing column, changing column attribute, etc.
  • Renaming table –  we will show you how to rename a table using RENAME TABLE statement.
  • Removing a column from a table – shows you how to use the ALTER TABLE DROP COLUMN statement to remove one or more columns from a table.
  • Adding new column to a table – this tutorial shows you how to add one or more columns to existing table using ALTER TABLE ADD COLUMN statement.
  • Using MySQL DROP TABLE statement to remove tables – shows you how to remove existing tables using DROP TABLE statement.
  • MySQL temporary table – discusses about MySQL temporary table and shows you step by step how to manage temporary tables.
  • Managing MySQL database indexes – you will learn how to work with MySQL indexes and how to take advantages of indexes to speed up the data retrieval.
  • MySQL TRUNCATE TABLE – this tutorial shows you how to use the TRUNCATE TABLE statement to delete all data in a table.

MySQL Globalization

  • MySQL character Set – this tutorial discusses about MySQL character set and shows you step by step how to perform various operations on character sets.
  • MySQL collation – this tutorial discusses about MySQL collation and shows you how to set character set and collations for the MySQL server, database, tables and columns.

Learn SQL The Hard Way
(http://sql.learncodethehardway.org/)
This book will teach you the 80% of SQL you probably need to use it effectively, and will mix in concepts in data modeling at the same time. If you’ve been fumbling around building web, desktop, or mobile applications because you don’t know SQL, then this book is for you. It is written for people with no prior database, programming, or SQL knowledge, but knowing at least one programming language will help.

Learn SQL The Hard Way – Table Of Contents


Databases – The ODIN Project
(http://www.theodinproject.com/web-development-101/databases)

Compared to a normal programming language like you’ve already learned, SQL (Structured Query Language), which is used to query databases, is a very simple syntax… there are only a small handful of commands to learn.

Points to Ponder

Look through these now and then use them to test yourself after doing the tasks

  • What is a database?
  • What are relational databases?
  • How are relational databases different from XML?
  • What is SQL?
  • What is SQL used for?
  • What does CRUD stand for?
  • Why is the idea of “CRUD” so important for web apps?
  • How do you get all the records from a table in SQL?
  • How do you insert a record in SQL?
  • What is a primary key?
  • What is a foreign key?

Tasks:

1. Look at Zed Shaw’s Learrn SQL The Hard Way (http://sql.learncodethehardway.org/book/introduction.html). Only read the introduction (unless you’re feeling ambitious).

2. View YouTube video An Introduction to Relational Databases (https://www.youtube.com/watch?v=z2kbsG8zsLM) to get a feel for relational databases and some more exposure to the terminology we’ll use.

Uploaded on 29 May 2009
Beginning web developers quickly realize learning a programming language is only half of the battle. They’ll also need to figure out how to manage the website data, a task most commonly done using a relational database. This video introduces the concept of a relational database, showing how data is organized in a manner that facilitates organization, management, and retrieval.
3. View Stanford University’s Mini  Database Courses (https://lagunita.stanford.edu/courses/DB/2014/SelfPaced/about)
Stanford University’s Database YouTube playlist (https://www.youtube.com/playlist?list=PL6hGtHedy2Z4EkgY76QOcueU8lAC4o6c3)
4. Try the much simpler and shorter Khan Academy’s Welcome to SQL tutorial (https://www.khanacademy.org/computing/hour-of-code/hour-of-sql/v/welcome-to-sql)
Make sure to do the automated assignments as well for the SQL section! It’s easier if you have a pen-and-paper handy to try and visualize what’s going on.

Additional Resources

Download SQL Basics (PDF)

  • Stanford’s Introduction to Databases course (https://www.coursera.org/course/db)
    Note: “Introduction to Databases” was one of Stanford’s three inaugural massive open online courses in the fall of 2011; it was offered again in MOOC format in 2013 and 2014. Materials from the MOOC offerings have been available for self-study on Coursera as well as on other platforms. Starting in summer 2014, the materials are now being offered on the OpenEdX platform as a set of smaller self-paced “mini-courses”, which can be assembled in a variety of ways to learn about different aspects of databases. All of the mini-courses are based around video lectures and/or video demos. Many of them include in-video quizzes to check understanding, in-depth standalone quizzes, and/or a variety of automatically-checked interactive programming exercises. Each mini-course also includes a discussion forum and pointers to readings and resources. Taught by Professor Jennifer Widom, the overall curriculum draws from Stanford’s popular Databases course. To explore and enroll in the new Databases mini-courses, please visit https://class.stanford.edu/courses/DB/2014/SelfPaced/about.

SQLSQL Tutorial
(http://www.w3schools.com/sql/)

SQL is a standard language for accessing databases.
Our SQL tutorial will teach you how to use SQL to access and manipulate data in: MySQL, SQL Server, Access, Oracle, Sybase, DB2, and other database systems.


PHP MySQL Database
(http://www.w3schools.com/php/php_mysql_intro.asp)

With PHP, you can connect to and manipulate databases.

MySQL is the most popular database system used with PHP.

What is MySQL?

  • MySQL is a database system used on the web
  • MySQL is a database system that runs on a server
  • MySQL is ideal for both small and large applications
  • MySQL is very fast, reliable, and easy to use
  • MySQL uses standard SQL
  • MySQL compiles on a number of platforms
  • MySQL is free to download and use
  • MySQL is developed, distributed, and supported by Oracle Corporation
  • MySQL is named after co-founder Monty Widenius’s daughter: My

Tizag TutorialsPHP / MySQL Tutorial
(http://www.tizag.com/mysqlTutorial/)

Download MySQL Tutorial (PDF)

MySQL is currently the most popular open source database server in existence. On top of that, it is very commonly used in conjunction with PHP scripts to create powerful and dynamic server-side applications.
MySQL has been criticized in the past for not supporting all the features of other popular and more expensive DataBase Management Systems. However, MySQL continues to improve with each release (currently version 5), and it has become widely popular with individuals and businesses of many different sizes.


MySQL Tutorial 1: Overview, Tables, Queries – Arachnoid
(http://arachnoid.com/MySQL/)

MySQL is a free, open-source database engine available for all major platforms. (Technically, MySQL is a relational database management system (RDBMS).) MySQL represents an excellent introduction to modern database technology, as well as being a reliable mainstream database resource for high-volume applications.

A modern database is an efficient way to organize, and gain access to, large amounts of data. A relational database is able to create relationships between individual database elements, to organize data at a higher level than a simple table of records, avoid data redundancy and enforce relationships that define how the database functions.

These articles will familiarize the reader with basic database concepts, move on to MySQL, and show how to create a useful database, step by step.


Introduction to MySQLMySQL Tutorial
(http://www.w3resource.com/mysql/mysql-tutorials.php)

MySQL is (as of July 2013) the world’s most widely used open-source relational database management system (RDBMS), enabling the cost-effective delivery of reliable, high-performance and scalable Web-based and embedded database applications. It is widely-used as the database component of LAMP (Linux, Apache, MySQL, Perl/PHP/Python) web application software stack.
MySQL was developed by Michael Widenius and David Axmark in 1994. Presently MySQL is maintained by Oracle (formerly Sun, formerly MySQL AB).
MySQL tutorial of w3resource is a comprehensive tutorial to learn MySQL(5.6). We have hundreds of examples covered, often with PHP code. This helps you to learn how to create PHP-MySQL based web applications.

What is MySQL?

MySQL Editions

Who uses MySQL

Supported platforms Third party tools & Front ends tools

Key features, relational database features of MySQL

w3resource MySQL tutorials

Database Management System


tech on the netMySQL Tutorial
(http://www.techonthenet.com/mysql/)

MySQL is the world’s most popular open-source relational database technology.
Our tutorial will start with the basics of MySQL such as how to retrieve and manipulate data. Then we will move to the more advanced topics such as how to create tables, functions, procedures, and triggers. We will conclude with a review of the functions that are proprietary to MySQL.
With this tutorial, you should be on your way to becoming proficient in MySQL and its programming language.


Udemy FREE Online Video Tutorial – MySQL for Beginners
(https://www.udemy.com/mysql-db-for-beginners/)

Learn how to Create, Use and Handle a MySQL Database from Scratch.

MySQL Database Being the Second most widely used Relational Database makes it one of the database to learn if you are looking forward to develop a database driven application.
Are you a Web Developer? An Application Developer? or A Programmer? Then MySQL Database should be one of the Mandatory Database in your “To Learn” list. If you don’t know MySQL yet or if you are new to any database then this is your go to course to learn SQL and also MySQL Database.
If you are learning or want to learn PHP, PYTHON, PEARL or RUBY then you should learn MySQL as well as this is the Database that is used by most of the developer who prefer the previously mentioned programming languages. If you are Web Developer and you don’t know MySQL yet then most won’t recommend you to call yourself as a Web Developer yet.
MySQL is one of the most used and go to database for pretty much all the web developer who pick PHP, PEARL or Python without a second thought.

  • Installation of MySQL Server in your Local System
  • Setting up and Configuring MySQL Database Server
  • Creating a Database with data
  • Maintaining the Database
  • Designing a better database
  • Covers all the basic you should know to create a complex database driven application

 Udemy FREE Online Video Tutorial – Learn Database Design with MySQL
(https://www.udemy.com/learn-database-design-with-mysql/)

A Complete Course to Master Database Design using MySQL

Database design is one of the most important aspects of Web programming. Successful implementation of any system with Data Storage will always need proper database design. In order to create great database design you will not only have to master the Database technology but will have to master database design process and normalization.
This course will teach you the nuances of proper database design. It will teach you all the hidden tips and tricks and will ensure that you learn all the major concepts of a proper database design. This course will also teach you SQL and you will be a SQL power user by the end of this course.
You will start with basic introduction to data storage and will follow it up with storage engines and other tools. You will also learn about MySQL installation and database design process. Database design , normalization, structure mapping, keys and junction tables comes next.
The next units will teach you SQL and Advance SQL and you will also learn to use PHP with MySQL. So this complete Database course and will surely help you become a Database Design Guru.

  • Over 31 lectures and 6.5 hours of content!
  • To Learn Database design Process
  • To Learn Database Normalization
  • To Learn Database development using MySQL
  • To Master SQL
  • To Learn to use PHP with MySQL

Udemy FREE Online Video Tutorial – Beginner PHP and MySQL Tutorial
(https://www.udemy.com/php-mysql-tutorial/)

Learn PHP and MySQL and start developing web apps like a pro!

PHP and MySQL are incredibly powerful open source technologies that allow people to create functional websites and apps that go way beyond basic HTML. While it can seem intimidating to someone with no background in coding, working with PHP is much easier than many realize. With the right guidance and a desire to learn, most people can learn how to put together a functional web app in a few days!
This PHP / MySQL Tutorial Video Course is narrated by Robert Tucker, a long-time trainer, lecturer and consultant who specializes in helping people learn how to use technology to solve real world problems. In this high-impact course, Robert walks users through the creation of a functional PHP / MySQL interface from beginning to end, explaining where needed the important technical points without relying on excessive jargon. This is not an overview of complex theory, but a hands-on primer that will allow even beginners to create usable solutions quickly!
Robert shows you how to make the most from these free technologies used by everyone from small startups to the biggest technology companies in the world.

  • Over 156 lectures and 10.5 hours of content!
  • How to download and install PHP and MySQL tools and frameworks onto a server and home machine.
  • How to configure relevant setting to match the needs of your project.
  • How to work between a user interface and a database back-end that stores critical information.
  • How to plan and apply PHP and MySQL to specific examples and finally your own real world projects.

What is the target audience?

  • Anyone who wants to build a website that goes beyond the requirements of basic HTML and CSS.
  • Anyone who wants to learn how to build an app that can handle data and interface with end users at the same time.
  • Anyone who wants to learn how MySQL can function as a database solution.
  • Anyone who wants to learn basic programming and development skills without days of digging through technical books.

 SQL Basics – Hunter Ducharme – Published with GitBook

Download PDF version

1. Introduction
2. Basic Syntax
3. Basic Select Statements
4. Table Variables & Set Operators
5. Subqueries in the Where Clause
i. Using Operators in a Subquery
6. Subqueries in the From & Select Clause
7. The ‘Join’ Family Operators
i. Inner Join
ii. Natural Join
iii. Outer Join
8. Aggregation
i. Aggregation Functions
ii. Aggregation Clauses
9. Data Modification Statements
i. Insert Commands
ii. Delete Commands
iii. Update Commands
10. Glossary