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
AmitDiwan has Published 10740 Articles
AmitDiwan
261 Views
To maintain the custom order of IDs, use ORDER BY CASE statement. Let us first create a table −mysql> create table DemoTable1550 -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert ... Read More
AmitDiwan
434 Views
For this, you can use the INSERT INTO SELECT statement. To format the date, use the DATE_FORMAT() function. Let us first create a table −mysql> create table DemoTable -> ( -> DateOfJoining datetime, -> JoiningDate text -> ); Query OK, 0 rows affected (0.79 sec)Insert some ... Read More
AmitDiwan
310 Views
There is no difference between show index, show indexes and show keys. They have similar meaning.Let us first create a table −mysql> create table DemoTable1549 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20) -> ); Query OK, 0 rows affected (0.82 ... Read More
AmitDiwan
352 Views
For this, you can use the CASE statement. To sort, use the ORDER BY clause. Let us first create a table −mysql> create table DemoTable -> ( -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(20) -> ); Query OK, 0 rows affected (0.54 ... Read More
AmitDiwan
923 Views
To fetch records from comma separated values, use MySQL FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable1548 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> ArrayListOfMarks varchar(100) -> ); Query OK, 0 rows affected (0.88 sec)Insert ... Read More
AmitDiwan
223 Views
For this, you need to compare and find the difference between the current date and the result date of students. This can be done with AND operator along with DATEDIFF().Let us first create a table −mysql> create table DemoTable1547 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY ... Read More
AmitDiwan
297 Views
Let us first create a table −mysql> create table DemoTable1546 -> ( -> Number varchar(20) -> ); Query OK, 0 rows affected (0.99 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1546 values('145 78 90'); Query OK, 1 row affected (0.17 sec) mysql> ... Read More
AmitDiwan
236 Views
To understand, let us create a stored procedure. Here, we have 2 select statements in the stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE select_statement() -> BEGIN -> SELECT "HI" AS `FIRST VALUE`; -> SELECT "HELLO" AS `SECOND VALUE`; -> END -> // ... Read More
AmitDiwan
219 Views
For conditions, use CASE statement in MySQL. Let us first create a table −mysql> create table DemoTable1545 -> ( -> Id int, -> FirstName varchar(20) -> ); Query OK, 0 rows affected (1.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1545 ... Read More
AmitDiwan
1K+ Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name text -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John [John] Smith'); Query OK, 1 row affected (0.30 sec) mysql> ... Read More