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 10744 Articles
AmitDiwan
315 Views
For this, use ORDER BY FIELD(). Let us first create a table −mysql> create table DemoTable( ClientId varchar(40), ClientName varchar(40) ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('987_John', 'John'); Query OK, 1 row affected (0.33 ... Read More
AmitDiwan
148 Views
Let us first create a table −mysql> create table DemoTable( ArrivalDate timestamp ); Query OK, 0 rows affected (1.96 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-09-14 17:25:00'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('2019-09-13 17:25:00'); Query OK, ... Read More
AmitDiwan
158 Views
Let us first create a table −mysql> create table DemoTable ( StudentId int, StudentFirstName varchar(100), StudentLastName varchar(100) ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1000, 'Adam', 'Smith'); Query OK, 1 row affected (0.17 sec) ... Read More
AmitDiwan
504 Views
For this, use SUM() along with GROUP BY. Let us first create a table −mysql> create table DemoTable ( CustomerName varchar(100), Product_1_Price int, Product_2_Price int ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 67, ... Read More
AmitDiwan
86 Views
Let us first create a table −mysql> create table DemoTable ( FirstName varchar(100) ); Query OK, 0 rows affected (0.96 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Robert'); Query OK, ... Read More
AmitDiwan
209 Views
For this, use aggregate function count(*) to count to GROUP BY to group. Let us first create a table −mysql> create table DemoTable ( UserName varchar(100), UserPostMessage text ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable ... Read More
AmitDiwan
98 Views
Let us first create a table −mysql> create table DemoTable ( Id int, Name varchar(100) ); Query OK, 0 rows affected (0.94 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 'Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable ... Read More
AmitDiwan
274 Views
For this, use aggregate function MIN() along with WHERE clause. Let us first create a table −mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(11); Query OK, 1 row affected ... Read More
AmitDiwan
136 Views
Let us first create a table −mysql> create table DemoTable ( UserName varchar(100) ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Smith_John'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Smith_Adam'); Query OK, 1 ... Read More
AmitDiwan
2K+ Views
For this, you can use BETWEEN keyword. Let us first create a table −mysql> create table DemoTable ( ExpiryDate date ); Query OK, 0 rows affected (0.55 sec)Note − Let’s say the current date is 2019-08-18.Insert some records in the table using insert command −mysql> insert into DemoTable values('2018-01-21'); ... Read More