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 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 will learn how to create a table in MySQL using the MySQL CREATE TABLE statement. Learn more: Delete a table in MySQL ALTER TABLE statement in MySQL ADD COLUMN statement in MySQL CREATE TABLE Syntax The syntax of the MySQL CREATE TABLE … 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

MySQL ALTER TABLE Statement with Examples

How to Use the ALTER TABLE Statement In this tutorial, you’ll learn how to use the MySQL ALTER TABLE statement to add, drop, and modify columns in an existing table. You also can use the ALTER TABLE statement to add and drop a primary key, a foreign key, and other constraints on the table. Adding a single column using … 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 will learn how to use the MySQL CASE statement, a flow control statement in MySQL that allows you to execute a block of SQL code when one condition is TRUE and another block of SQL code when that condition evaluates to FALSE. Learn more: … 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 This tutorial explains how to use MySQL DATE_ADD() function, which adds a time or date interval to a given date and returns a new date. To subtract a time or date interval from a given time, use the DATE_SUB() function. MySQL DATE_ADD() Syntax The syntax of the DATE_ADD() … 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 returns a new date. To add the date and time to a given date, use the DATE_ADD() function. MySQL DATE_SUB() Syntax The syntax of the DATE_SUB() … Read more

MySQL NULLIF Function with Examples

How to Use the MySQL NULLIFF() Function In this tutorial, you will learn how to use the MySQL NULLIF() function, which compares two expressions and returns NULL if equal; otherwise 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 The following … Read more

MySQL LOCATE Function with Examples

How to Use the MySQL LOCATE Function This tutorial explains how to use the MySQL LOCATE function, which returns the position where the substring first appears in a given string. See also: MySQL COUNT() function MySQL SUM() function MySQL SUBSTRING() function MySQL LOCATE() Syntax The syntax of the LOCATE function is as follows: LOCATE(substring, string) … Read more

MySQL IFNULL() Function with Examples

How to Use the MySQL IFNULL() Function In this tutorial, you will learn how to use the MySQL IFNULL() function that returns the specified value if the expression is NULL; otherwise returns that expression. If you want to compare two expressions and return NULL if they are equal, use the NULLIF() function. IFNULL() Syntax The … 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 with Examples

How to Use the MySQL LOOP Statement In this tutorial, you will learn how to use a LOOP statement in MySQL. A LOOP statement is a simple loop construct that allows you to repeatedly execute a block of SQL code consisting of one or more SQL statements ending with a semicolon (;). There are two … Read more