
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
Found 4381 Articles for MySQL

814 Views
To set conditions, use MySQL CASE statement. Let us first create a −mysql> create table DemoTable1481 -> ( -> PlayerScore int -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert −mysql> insert into DemoTable1481 values(454); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable1481 values(765); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1481 values(890); Query OK, 1 row affected (0.09 sec)Display all records from the table using select −mysql> select * from DemoTable1481;This will produce the following output −+-------------+ | PlayerScore | +-------------+ | ... Read More

235 Views
Yes, we can fetch, but use MySQL OR for conditions. Let us first create a −mysql> create table DemoTable1421 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20), -> EmployeeSalary int -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert −mysql> insert into DemoTable1421(EmployeeName, EmployeeSalary) values('Chris', 10000); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1421(EmployeeName, EmployeeSalary) values('Bob', 15000); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1421(EmployeeName, EmployeeSalary) values('David', 8000); Query OK, 1 row affected (0.09 sec) mysql> insert ... Read More

926 Views
For this, you can use MySQL IN(). Let us first create a −mysql> create table DemoTable1420 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FirstName varchar(20), -> LastName varchar(20), -> Age int -> ); Query OK, 0 rows affected (1.12 sec)Insert some records in the table using insert −mysql> insert into DemoTable1420(FirstName, LastName, Age) values('Chris', 'Brown', 23); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1420(FirstName, LastName, Age) values('David', 'Miller', 22); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1420(FirstName, LastName, Age) values('John', 'Smith', 24); Query OK, ... Read More

942 Views
To convert, use MySQL TIME_FORMAT(). Let us first create a −mysql> create table DemoTable1419 -> ( -> ArrivalTime time -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command. Here, we have inserted time records −mysql> insert into DemoTable1419 values('12:30:45'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1419 values('11:00:55'); Query OK, 1 row affected (0.45 sec) mysql> insert into DemoTable1419 values('09:59:34'); Query OK, 1 row affected (0.16 sec)Display all records from the table using select −mysql> select * from DemoTable1419;This will produce the following output −+-------------+ | ... Read More

102 Views
Let us first create a −mysql> create table DemoTable1418 -> ( -> EmployeeCode text -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert −mysql> insert into DemoTable1418 values('EMP-2110/Carol'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1418 values('EMP-1900/David'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1418 values('EMP-2345/Mike'); Query OK, 1 row affected (0.17 sec)Display all records from the table using select −mysql> select * from DemoTable1418;This will produce the following output −+----------------+ | EmployeeCode | +----------------+ | EMP-2110/Carol | | EMP-1900/David | | EMP-2345/Mike ... Read More

117 Views
To order, use ORDER BY and to fetch only the 2nd ordered record, use MySQL LIMIT and set offset as well. Let us first create a −mysql> create table DemoTable1417 -> ( -> CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CustomerName varchar(20), -> ShippingDate date -> ); Query OK, 0 rows affected (1.10 sec)Insert some records in the table using insert −mysql> insert into DemoTable1417(CustomerName, ShippingDate) values('Chris', '2019-01-21'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1417(CustomerName, ShippingDate) values('David', '2018-12-01'); Query OK, 1 row affected (0.55 sec) mysql> insert into DemoTable1417(CustomerName, ShippingDate) ... Read More

206 Views
For this, you can use SUBSTRING_INDEX(). Let us first create a −mysql> create table DemoTable1416 -> ( -> StudentCode varchar(100) -> ); Query OK, 0 rows affected (1.56 sec)Insert some records in the table using insert −mysql> insert into DemoTable1416 values('101/John/Smith'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1416 values('901/Carol/Taylor'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1416 values('400/David/Miller'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select −mysql> select * from DemoTable1416;This will produce the following output −+------------------+ | StudentCode | +------------------+ | ... Read More

2K+ Views
For this, use EXTRACT(), that would allow you to extract specific month records. For example, to add all the prices in January (irrespective of the year).Let us first create a −mysql> create table DemoTable1415 -> ( -> ProductPurchaseDate date, -> ProductPrice int -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert −mysql> insert into DemoTable1415 values('2019-01-12', 560); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1415 values('2018-01-14', 1060); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1415 values('2017-03-21', 780); Query OK, 1 row affected (0.11 ... Read More

267 Views
For this, use MySQL MIN(). Let us first create a −mysql> create table DemoTable1414 -> ( -> BookTitle varchar(40), -> BookPrice int -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert −mysql> insert into DemoTable1414 values('Deep dive using java', 560); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1414 values('C++ in depth', 360); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1414 values('Data structure in C', 590); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1414 values('Algorithm in C++', 1090); Query OK, 1 ... Read More

283 Views
The fastest and easiest way is to use the MySQL BETWEEN keyword. Let us first create a −mysql> create table DemoTable1413 -> ( -> EmployeeName varchar(20), -> EmployeeJoiningDate datetime -> ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert −mysql> insert into DemoTable1413 values('Chris', '2018-09-28 11 :10 :50'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1413 values('David', '2019-09-28 11:10:50'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1413 values('Mike', '2019-09-29 12:40:00'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1413 values('Carol', '2019-09-28 12:06:10'); ... Read More