MySQL GROUP BY Clause with Examples

How to Use the GROUP BY Clause in MySQL In this tutorial, you’ll learn how to use the MySQL GROUP BY clause in the SELECT query to group a set of records into summary records. GROUP BY is used to group a set of records by one or more columns, and we often use it with aggregate functions such as COUNT(), SUM(), AGV(), MAX(), … Read more

MySQL ORDER BY Clause with Examples

How to Use the ORDER BY Clause in MySQL In this tutorial, you’ll learn how to retrieve records in a table from a MySQL database sorted in ascending or descending order. To retrieve the records sorted in ascending or descending order, you use the MySQL ORDER BY clause along with SELECT. The ORDER BY clause is as follows: SELECT column1,column2,column3,…,columnN … Read more

MySQL CREATE DATABASE with Examples

How to Use the MySQL CREATE DATABASE Statement In this tutorial, you’ll learn how to create a new database in MySQL using the CREATE DATABASE statement. CREATE DATABASE Syntax To create a database, you use the CREATE DATABASE statement as follows: CREATE DATABASE [IF NOT EXISTS] database_name [CHARACTER SET charset_name] [COLLATE collation_name] Remarks Database_name must be unique within the MySQL … Read more

MySQL CREATE TABLE with Examples

How to Create Tables in MySQL Using the CREATE TABLE Statement In this tutorial, you’ll learn how to create a table in MySQL using the MySQL CREATE statement. CREATE TABLE Syntax The syntax of the MySQL CREATE TABLE statement is as follows: CREATE TABLE [IF NOT EXISTS] table_name(    column_name(s)) ENGINE=storage_engine; To define a column for the table in … Read more

MySQL LEFT JOIN with Examples

How to Use LEFT JOIN in MySQL In this tutorial, you’ll learn how to use the MySQL LEFT JOIN.  LEFT JOIN is used to select all records from the left table and the matched records from the right table. LEFT JOIN Syntax SELECT column_name(s)FROM table1LEFT JOIN table2 ON table1.column_name = table2.column_nam Examples Suppose you have two tables, … Read more

Excel AVERAGEIF Function with Examples

How to Use the Excel AVERAGEIF Function In this tutorial, you’ll learn how to use the Excel AVERAGEIF function. AVERAGEIF is a function to calculate the average of a group of numbers in a range of cells that meet single criteria. AVERAGEIF Syntax The syntax of the AVERAGEIF() function is as follows: =AVERAGEIF (range, criteria, [average_range]) Arguments range: A range … Read more

INDEX and MATCH Excel with Examples

How to Use INDEX and MATCH with Examples In this tutorial, you’ll learn how to use the combination of INDEX() and MATCH() to lookup a value and retrieve some other related information. First, learn INDEX() and MATCH(), and second, learn to use the combination of INDEX() and MATCH(). INDEX INDEX() returns a value or a reference to specified cells from within … Read more

MySQL CASE Statement with Examples

How to Use the MySQL CASE Statement In this tutorial, you’ll learn how to use the MySQL CASE statement. CASE is a MySQL flow control statement that allows you to execute a block of SQL code when a condition is TRUE and execute another block of SQL code when the condition evaluates to FALSE. MySQL CASE Syntax The syntax of the … Read more

MySQL DATE_FORMAT() Function with Examples

How to Use the MySQL DATE_FORMAT() Function In this tutorial, you’ll learn how to use the MySQL DATE_FORMAT() function. DATE_FORMAT() formats a date as specified. MySQL DATE_FORMAT() Syntax The syntax of the DATE_FORMAT() function is as follows: DATE_FORMAT(date, format) Arguments date: Required. The date that you want to format. format: Required. The format to use. … Read more

C# foreach Statement with Examples

How to Use the foreach Statement in C# This tutorial describes how to use the foreach statement with examples in C#. The foreach statement executes a block of code for each element of a given collection, such as a list, dictionary, or array. Related C# tutorials: A for loop statement in C# A while loop … Read more

MySQL DATE_ADD() Function with Examples

How to Use the MySQL DATE_ADD() Function In this tutorial, you’ll learn how to use the MySQL DATE_ADD() function. The DATE_ADD() function adds a time and date interval to a given date and then returns a new date. MySQL DATE_ADD() Syntax The syntax of the DATE_ADD() function is as follows: DATE_ADD(date, INTERVAL expression unit) Arguments The date, … Read more

MySQL DATE_SUB() Function with Examples

How to Use the MySQL DATE_SUB() Function In this tutorial, you’ll learn how to use the MySQL DATE_SUB() function. The DATE_SUB() function subtracts a time and date interval from a given date and then returns a new date. MySQL DATE_SUB() Syntax The syntax of the DATE_SUB() function is as follows: DATE_SUB(date, INTERVAL expression unit) Arguments The date, … Read more

MySQL NULLIF Function with Examples

How to Use the MySQL NULLIFF() Function In this tutorial, you’ll learn how to use the MySQL NULLIF() function. NULLIF is a function to compare two expressions and return NULL if they are equal. Otherwise, it returns the first expression. MySQL NULLIF() Syntax The syntax of the NULLIF() function is as follow: NULLIF (expression_1, expression_2) NULLIF Examples Example 1 … Read more

MySQL LOCATE Function with Examples

How to Use the MySQL LOCATE Function In this tutorial, we’ll learn how to use the MySQL LOCATE function. LOCATE returns the position of the first occurrence of substring in a given string. MySQL LOCATE() Syntax The following is the syntax of the LOCATE function: LOCATE(substring, string) or: LOCATE(substring, string, position) Remarks LOCATE returns 0 … Read more

MySQL CROSS JOIN with Examples

How to Use the MySQL CROSS JOIN In this tutorial, we’ll learn how to use the CROSS JOIN in MySQL. CROSS JOIN returns the Cartesian product of 2 tables, returning all possible combination of all records. For example, suppose we join the employees table, containing 4 records, and departments table, containing 3 records. Since CROSS … Read more

MySQL LOOP Statement with Examples

How to Use the MySQL LOOP Statement In this tutorial, you’ll learn how to use the MySQL LOOP statement.  LOOP is a simple loop construct that enables repeated execution of a block of SQL code, which consists of one or more statements, each terminated by a semicolon (;). In MySQL, there are two other flow control statements, REPEAT and WHILE. Like … Read more