- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6702 Articles for Database
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
For this, you can use IFNULL() or COALESCE(). Let us first create a table −mysql> create table DemoTable1849 ( ClientFirstName varchar(20), ClientLastName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1849 values('John', NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1849 values(NULL, 'Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1849 values(NULL, NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1849 values('Chris', 'Brown'); Query OK, 1 row affected (0.00 sec)Display all ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
748 Views
To add time to datetime, use ADDTIME() function in MySQL. Let us first create a table −mysql> create table DemoTable1848 ( ShippingDate datetime ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1848 values('2019-10-11 12:30:45'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1848 values('2019-01-12 10:00:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1848 values('2019-12-03 17:30:00'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1848; This will produce ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
372 Views
Let us first create a table −mysql> create table DemoTable1847 ( GameStatus ENUM('PENDING', 'COMPLETED', 'CANCELLED') ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1847 values('PENDING'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1847 values('COMPLETED'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1847 values('CANCELLED'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1847; This will produce the following output −+------------+ | GameStatus | +------------+ | PENDING ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
666 Views
For this, use MONTH() and YEAR(). Let us first create a table −mysql> create table DemoTable1846 ( PurchaseDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1846 values('2019-01-10'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1846 values('2019-12-24'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1846 values('2018-09-21'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1846 values('2017-10-26'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
789 Views
For this, you can use the concept of INTERVAL and DATE_SUB(). Let us first create a table −mysql> create table DemoTable1845 ( ArrivalDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1845 values('2019-12-02'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1845 values('2019-11-18'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1845 values('2019-12-18'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1845 values('2019-12-25'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1845 values('2019-11-15'); Query ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
For this, you can use CONCAT() and round(). Let us first create a table −mysql> create table DemoTable1844 ( Number int, TotalNumber int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1844 values(50, 500); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1844 values(80, 500); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1844 values(98, 500); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1844 values(45, 500); Query OK, 1 row affected (0.00 sec)Display all ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
395 Views
For this, use MySQL YEAR() function. Let us first create a table −mysql> create table DemoTable1843 ( StartDate date, EndDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1843 values('2019-01-21', '2019-10-12'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1843 values('2018-10-12', '2018-12-31'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1843 values('2016-04-01', '2017-05-02'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1843;This will produce the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
378 Views
To multiply with NULL row, you can use COALESCE(). Let us first create a table −mysql> create table DemoTable1842 ( NumberOfItems int, Amount int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1842 values(10, 40); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1842 values(20, 5); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1842 values(NULL, 10); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1842;This ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
100 Views
For this, you can use WHERE clause along with subquery. Let us first create a table −mysql> create table DemoTable1840 ( UserName varchar(20), UserType ENUM('GUEST', 'ADMIN') ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1840 values('Chris', 'Admin'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1840 values('David', 'Guest'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1840 values('Chris', 'Guest'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
181 Views
The syntax for the fastest way is given below. Here, we have used INSERT INTO just once and formed an optimized way −insert into yourTableName values(NULL, yourValue1', yourValue2), (NULL, yourValue1', yourValue2), ....N;Let us first create a table −mysql> create table DemoTable1839 ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(20), ClientAge int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1839 values(NULL, 'Chris', 29), (NULL, 'Chris', 29), (NULL, 'Chris', 29), (NULL, 'Chris', 29), (NULL, 'Chris', 29), (NULL, 'Chris', ... Read More