AmitDiwan has Published 10744 Articles

Update only a single column value in MySQL

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 10:37:11

305 Views

Let us first create a table −mysql> create table DemoTable1605    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20),    -> StudentCountryName varchar(20)    -> ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert ... Read More

How to ignore specific records and add remaining corresponding records (numbers) in MySQL?

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 10:26:29

129 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Name varchar(20),    -> Amount int    -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 200); Query OK, 1 row affected ... Read More

Update with multiple values in MySQL WHERE clause

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 07:38:16

2K+ Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Name varchar(20),    -> Age int,    -> CountryName varchar(10)    -> ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

Working with WHERE IN() in a MySQL Stored Procedure

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 07:36:44

1K+ Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected ... Read More

How to sum cells in a column if a condition is met in another column with MySQL?

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 07:31:19

1K+ Views

For this, you can use the aggregate function SUM() along with the GROUP BY clause. Let us first create a table −mysql> create table DemoTable    -> (    -> EmployeeName varchar(20),    -> JoiningDate date,    -> Salary int    -> ); Query OK, 0 rows affected (0.54 sec)Insert ... Read More

Add records from corresponding duplicate values in another column with MySQL

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 07:30:06

245 Views

For this, you can use the aggregate function SUM() along with the GROUP BY clause. Let us first create a table −mysql> create table DemoTable    -> (    -> Name varchar(20),    -> Value int    -> ); Query OK, 0 rows affected (2.08 sec)Insert some records in the ... Read More

Find specific records from a column with comma separated values in MySQL

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 07:28:16

875 Views

For this, you can use FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable    -> (    -> ListOfValue varchar(20)    -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('78, 89, 65'); Query OK, ... Read More

UPDATE with logical AND operator in MySQL

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 05:34:58

426 Views

For this, you can use AND operator with WHERE clause. Let us first create a table −mysql> create table DemoTable1616     -> (     -> StudentId int,     -> StudentName varchar(20),     -> StudentMarks int     -> ); Query OK, 0 rows affected (0.44 sec)Insert ... Read More

How to get the count of both present and absent students for a year in MySQL?

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 05:31:07

1K+ Views

For this, you can use IF() along with aggregate function SUM(). Let us first create a table −mysql> create table DemoTable1617     -> (     -> Attendance varchar(20),     -> CurrentYear int     -> ); Query OK, 0 rows affected (0.48 sec)Insert some records in the ... Read More

Select total from a MySQL table based on month

AmitDiwan

AmitDiwan

Updated on 28-Feb-2020 05:26:08

256 Views

For this, you can use GROUP BY MONTH(). Let us first create a table −mysql> create table DemoTable1628     -> (     -> PurchaseDate date,     -> Amount int     -> ); Query OK, 0 rows affected (1.55 sec)Insert some records in the table using insert ... Read More

Advertisements