Category: Database
Insert into a MySQL table or update if exists
While inserting rows into a table, there are times when the requirement is to insert the rows into a table, but if the key already exists, then update the value. This concept is also known as UPSERT, which is combining UPDATE with INSERT. In this article, we will be looking into : Insert or Update …
Find duplicate rows in MySQL
This article will look into how to find duplicate rows in MySQL based on one column and multiple columns. MySQL find duplicate rows based on one column : Using GROUP BY MySQL find duplicate rows based on one column : Using JOINS Find duplicate rows in MySQL with multiple columns : Using GROUP BY Find …
MySQL Delete Duplicate Rows but keep one
In this article, we will see how to delete duplicate rows from a table and keep only one using various ways, mainly: Delete the duplicate rows but keep latest : using GROUP BY and MAX Delete the duplicate rows but keep latest : using JOINS Delete the duplicate row but keep oldest : using JOINS …
MySQL IF EXISTS DROP Table
This article will be looking into how to drop a table if it exists in the database. How to DROP Table IF EXISTS in MySQL How to DROP Temporary Table IF EXISTS in MySQL How to DROP Table IF EXISTS in MySQL What all does a DROP TABLE statement does? DROP TABLE statement will remove one …
Every derived table must have its own alias[Solved]
In this article, we will be discussing the below points HOW TO FIX THE ERROR in MySQL : Every derived table must have its own alias Every derived table must have its own alias : JOIN Let’s get started, but first, we will look into the data we will be using in our examples. Assume …
Every derived table must have its own alias[Solved]Read More
Create Temporary Table in MySQL
We can create a temporary table in MySQL using the TEMPORARY keyword. A temporary table is a table that is visible only during the current session and hence has its scope in a single session only. Once the session is closed, access to the temporary table is closed as well. Two different sessions can use …
Retrieving the last record in each group[Solved] – MySQL
This article talks about how to get the last record in each group in a MySQL table, particularly Retrieving the last record in each group using GROUP BY Retrieving the last record in each group using JOINS Let’s get started by creating a table followed by inserting data into it to be used in the …
Retrieving the last record in each group[Solved] – MySQLRead More
MySQL select row with max date per user [Solved]
This article talks about selecting a row with a maximum date per user through different methods. Select row with max date per user using JOINS Select row with max date per user using MAX() function Let us get started by creating a table and inserting data into it, which we will be using across this …
MySQL select rows with date range[Solved]
In this article, we will be looking into selecting the records that fall between a particular date range. Table of Contents Select rows with date range using BETWEEN Select rows with date range using <= and >= Select rows with date range using DATE() function Let’s get started by looking into the table customer_sale_details, which we …
MySQL select row count [Everything around count()]
Count()Â function counts the number of rows. In this article, we will talk about how to get the row count in MySQL for different requirements, particularly: Count table rows Select row count of a query Select row count(distinct) Select row count GROUP BY MySQL select row count from all tables How to get the number of …