
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Rama Giri has Published 107 Articles

Rama Giri
825 Views
For this, you can use IFNULL(). Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Value int -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command ... Read More

Rama Giri
226 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Value int -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 85885); Query ... Read More

Rama Giri
2K+ Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('John'); Query ... Read More

Rama Giri
319 Views
For this, you can use DATEDIFF() function. The current date time is as follows −mysql> select now(); +---------------------+ | now() | +---------------------+ | 2019-06-09 19:15:56 | +---------------------+ 1 row in set (0.00 sec)Let us first create ... Read More

Rama Giri
509 Views
You can use UNION ALL for this.Let us get list 10, 20, 30, 40, 50 as a table with UNION ALL −mysql> select 10 Number UNION ALL select 20 Number UNION ALL select 30 Number UNION ALL select 40 Number UNION ALL select 50 Number;Output+--------+ | Number | +--------+ | 10 | | 20 | | 30 ... Read More

Rama Giri
916 Views
For concatenating a string field, use CONCAT() function. Let us first create a table −mysql> create table DemoTable -> ( -> SequenceId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentId varchar(100) -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using ... Read More

Rama Giri
121 Views
To work with auto incrementing column, you can set it as AUTO_INCREMENT while creating the table.Let us first create a table. Here, we have set the Id field as column since that would be our auto increment column −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FirstName varchar(20), ... Read More

Rama Giri
190 Views
Following is the syntax −select table_name, create_time from information_schema.TABLES where table_schema = 'yourDataBaseName' order by CREATE_TIME desc limit 1;Let us create the first table (Time: 2019-06-10 16:40:51) −mysql> create table DemoTable1 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge ... Read More

Rama Giri
475 Views
Yes, we can do that using the CASE statement. Let us first create a table −mysql> create table DemoTable -> ( -> isMarried boolean -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(true); Query ... Read More

Rama Giri
177 Views
If given a string containing a path to a file, the PHP basename() function will return the base name of the file. To get its equivalent in MySQL, you can use SUBSTRING_INDEX(). Let us first create a table −mysql> create table DemoTable -> ( -> Location varchar(200) ... Read More