Category: MySQL
MYSQL: CREATE A DATABASE
A database is a defined collection of logical, meaningful data, for example, a database of employees to store the name, addresses, employee numbers, and other relevant records of employee information. In this article, we will be discussing about creating databases in MYSQL, particularly the following topics:– MYSQL CREATE DATABASE – SYNTAX and EXAMPLE MYSQL CREATE …
MYSQL: UNION – tutorial with examples
We can use the UNION clause in MYSQL when we want to combine the results from multiple select queries and display the combined result in the output. In this article we will be discussing below topics, MYSQL: UNION QUERY SYNTAX MYSQL: UNION QUERY EXAMPLE MYSQL: UNION RESTRICTIONS MYSQL: UNION DISTINCT MYSQL: UNION ALL MYSQL: UNION …
MYSQL INSERT INTO
INSERT keyword in MYSQL is used to add the data to tables, specifically new rows. In this article, we will be talking about how to insert records in the tables. Table of Contents MYSQL INSERT INTO TABLE INSERTING MULTIPLE ROWS IN MYSQL MYSQL INSERT INTO SPECIFIC COLUMNS MYSQL INSERT INTO TABLE This is the most …
MYSQL INSERT WITH SELECT
In previous articles we learned to insert data into a table, feel free to checkout the article MYSQL INSERT INTO. This article will discuss how to insert data into a table by selecting the data from some other source, for example, another table. Table of Contents Advertisements MYSQL INSERT FROM SELECT: SINGLE TABLE MYSQL INSERT …
MySQL select row with max value
A lot of times, we need to get the rows that have maximum value in a column. There can be different requirements around the same, and hence there are various solutions. In this article, we will look into how to select only rows with maximum value on a column using, Max() function Left JOIN MySQL …
MySQL select row with max value for each group
While working with databases, we get many situations where we need to get records with max value for each group of grouped SQL results. While there are many solutions to it, we will be discussing a few of them. Table of Contents GROUP BY : MySQL select row with max value JOIN : MySQL select …
Mysql: select rows with MAX(Column value), DISTINCT by another column
We have a requirement to select the rows with maximum value in one column, DISTINCT, by another column in a table. In this article, we will be looking into the same using : ROW_NUMBER() Function and PARTITION BY INNER JOIN and LIMIT Let us start by looking into the data. Assume that we have a …
Mysql: select rows with MAX(Column value), DISTINCT by another columnRead More
Reset AUTO INCREMENT in MySQL
AUTO_INCREMENT is a useful feature provided in MySQL. It works as follows: it generates a numerical sequence to a column for every new row inserted.AUTO_INCREMENT generates unique numbers for identification purposes.We can manually define the starting of this sequence set by auto_increment and reset this value to some other value later. Whenever we reset the …
Reset AUTO_INCREMENT after Delete in MySQL
Sometimes the most recent entries get deleted from our table. After the rows are deleted, try to insert some rows. We can observe a gap in the number_values of the auto_increment column, which is ok in many cases. However, many times the requirement is to reset the auto_increment to maintain the sequence. Well, there is …
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 …