Categories

Filtering data (9)
[ Read More ]
Joining tables (1)
[ Read More ]
Modifying Data (1)
[ Read More ]
Querying data (1)
[ Read More ]
Sorting data (1)
[ Read More ]
Started with MySQL (5)
[ Read More ]

Articles

Copy a MySQL database on the same server

To copy a MySQL database, you need to follow these steps: First, create a new database using CREATE DATABASE statement. Second, export all the database objects and data of the database from...

How To Change MySQL Storage Engine

MySQL supports many kinds of storage engines that provide different capabilities and characteristics. For example, the InnoDB tables support transaction, whereas MyISAM does not. Querying the...

How To Compare Successive Rows Within The Same Table in MySQL

Suppose you have a table called inventory with the structure defined by the CREATE TABLE statement as follows: CREATE TABLE inventory( id INT AUTO_INCREMENT PRIMARY KEY, counted_date date...

How To Delete Duplicate Rows in MySQL

In the previous tutorial, we have shown you how to find duplicate values in a table. Once the duplicates rows are identified, you may want to delete them to clean up your data. Prepare sample data...

How To Find Duplicate Values in MySQL

Data duplication happens because of many reasons. Finding duplicate values is one of the important tasks that you must deal with when working with the databases. Setting up a sample table First,...

How To Map NULL Values To Other Meaningful Values

Dr.E.F.Codd, who is the creator of the relational model for the database, introduced the NULL concept in the relational database theory. According to Dr.E.F.Codd, NULL means unknown value or...

How To Select The nth Highest Record In MySQL

It is easy to select the highest or lowest record in the database table with the MAX or MIN function. However, it’s a little bit tricky to select the nth highest record. For example, the get the...

How to Get MySQL Today’s Date

Getting MySQL today’s date using built-in date functions Sometimes, you may want to query data from a table to get rows with date column is today, for example: SELECT column_list FROM...

Managing Hierarchical Data in MySQL Using the Adjacency List Model

Hierarchical data is everywhere. It can be blog categories, product hierarchies, or organizational structures. There are many ways to manage hierarchical data in MySQL and the adjacency list model...

MySQL Comment In Depth

Comments Comments can be used to document the purpose of an SQL statement or the logic of a code block in a stored procedure. When parsing SQL code, MySQL ignores the comments part. It only...

MySQL Compare Two Tables

In data migration, we often have to compare two tables to identify a record in one table that have no corresponding record in another table. For example, we have a new database whose schema is...

MySQL Copy Table With Examples

MySQL copy table to a new table Copying data from an existing table to a new one is very useful in some cases such as backing up data and replicating the production data for testing. To copy data...

MySQL DELETE

Introduction to MySQL DELETE statement To delete data from a table, you use the MySQL DELETE statement. The following illustrates the syntax of the DELETE statement: DELETE FROM table_name WHERE...

MySQL IS NULL

Introduction to MySQL IS NULL operator To test whether a value is NULL or not, you use the  IS NULL operator. Here is the basic syntax of the IS NULL operator: value IS NULL If the value is...

MySQL Insert

Introduction to the MySQL INSERT statement The INSERT statement allows you to insert one or more rows into a table. The following illustrates the syntax of the INSERT statement: INSERT INTO...

MySQL NULL: The Beginner’s Guide

Introduction to MySQL NULL values In MySQL, a NULL value means unknown. A NULL value is different from zero (0) or an empty string ''. A NULL value is not equal to anything, even itself. If you...

MySQL REGEXP: Search Based On Regular Expressions

A regular expression is a special string that describes a search pattern. It is a powerful tool that gives you a concise and flexible way to identify strings of text e.g., characters, and words,...

MySQL ROW_NUMBER, This is How You Emulate It

Notice that MySQL has supported the ROW_NUMBER() since version 8.0. If you use MySQL 8.0 or later, check it out ROW_NUMBER() function. Otherwise, you can continue with the tutorial to learn how to...

MySQL Reset Auto Increment Values

MySQL provides you with a useful feature called auto-increment. You can assign the AUTO_INCREMENT attribute to a column of a table to generate a unique identity for the new row. Typically, you use...

MySQL Row Count: How to Get Row Count in MySQL

Getting MySQL row count of a single table To get the row count of a single table, you use the COUNT(*) in a SELECT statement as follows: SELECT COUNT(*) FROM table_name; For example,...

MySQL SELECT INTO Variable

MySQL SELECT INTO Variable syntax To store query result in one or more variables, you use the SELECT INTO variable syntax: SELECT c1, c2, c3, ... INTO @v1, @v2, @v3,... FROM...

MySQL Select Random Records

  Sometimes, you have to select random records from a table, for example: Selecting some random posts in a blog and display them in the sidebar. Selecting a random quote for displaying “quote...

MySQL UUID Smackdown: UUID vs. INT for Primary Key

Introduction to MySQL UUID UUID stands for Universally Unique IDentifier. UUID is defined based on RFC 4122, “a Universally Unique Identifier (UUID) URN Namespace). UUID is designed as a number...

MySQL Variables

Introduction to MySQL user-defined variables Sometimes, you want to pass a value from an SQL statement to another SQL statement. To do this, you store the value in a MySQL user-defined variable in...