- 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)
122 Views
To view cascades, use SHOW CREATE TABLE in MySQL. Let us first create a table −mysql> create table DemoTable1378 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeId varchar(20), -> EmployeeFirstName varchar(20), -> EmployeeLastName varchar(20), -> EmployeeCountryName varchar(40), -> EmployeeAge int, -> EmployeeSalary int, -> UNIQUE(EmployeeFirstName, EmployeeSalary), -> INDEX First_Last_NameIndex(EmployeeFirstName, EmployeeLastName) -> ); Query OK, 0 rows affected (0.93 sec)Let us now view cascades in MySQL −mysql> show create table DemoTable1378;This will produce the following output −+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
113 Views
For this, use INTERVAL in MySQL. Let us first create a table −mysql> create table DemoTable1376 -> ( -> AdmissionDate date -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1376 values('2018-01-21'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1376 values('2017-12-01'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1376 values('2018-11-02'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1376 values('2019-03-14'); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement−mysql> select * from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
72 Views
The EXPLAIN keyword tells how MySQL executes the query. Let us first create a table −mysql> create table DemoTable1375 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FirstName varchar(20), -> INDEX FIRST_INDEX(FirstName) -> ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1375(FirstName) values('Chris'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable1375(FirstName) values('Bob'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1375(FirstName) values('Sam'); Query OK, 1 row affected (1.06 sec) mysql> insert into DemoTable1375(FirstName) values('David'); Query OK, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
3K+ Views
Use CASE WHEN for this in MySQL and set CASE condition inside the COUNT() method to count. Let us first create a table −mysql> create table DemoTable1374 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Score int -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1374(Name, Score) values('Chris', 45); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1374(Name, Score) values('David', 78); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1374(Name, Score) values('Bob', 45); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
871 Views
To display records like JSON format, use MySQL concat(). Let us first create a table −mysql> create table DemoTable1373 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentDetails text -> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command. Here, we haven’t inserted anything −mysql> insert into DemoTable1373 values(); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable1373 values(); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1373 values(); Query OK, 1 row affected (0.18 sec)Display all records from the table using ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
661 Views
For this, just update the table and subtract. Let us first create a table −mysql> create table DemoTable1372 -> ( -> Value int -> ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1372 values(500); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1372 values(100); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1372 values(900); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1372 values(1000); Query OK, 1 row affected (0.32 sec)Display all records from the table using select statement −mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
For this, use GROUP_CONCAT(). Do not use GROUP BY clause, since GROUP_CONTACT() is a better and quick solution.Let us first create a table −mysql> create table DemoTable1371 -> ( -> Id int, -> CountryName varchar(40) -> ); Query OK, 0 rows affected (0.89 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1371 values(100, 'US'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1371 values(100, 'UK'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1371 values(101, 'AUS'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable1371 values(101, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
94 Views
For only specific cells, set a condition with WHERE and use aggregate function SUM() to add. Let us first create a table −mysql> create table DemoTable1370 -> ( -> StudentName varchar(20), -> Marks int -> ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1370 values('Adam Smith', 56); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1370 values('Chris Brown', 67); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1370 values('Adam Smith', 69); Query OK, 1 row affected (0.20 sec) mysql> insert into ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
206 Views
Let us first create a table −mysql> create table DemoTable1369 -> ( -> BatchId varchar(20) -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command. We have inserted numbers here separated by a slash −mysql> insert into DemoTable1369 values('19/5'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1369 values('19/78'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1369 values('19/567'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1369 values('19/1234'); Query OK, 1 row affected (0.11 sec)Display all records from the table ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
385 Views
Let us first create a table −mysql> create table DemoTable1627 -> ( -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command.mysql> insert into DemoTable1627 values('John', 'Smith'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1627 values('John', 'Doe'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1627 values('Adam', 'Smith'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1627 values('Carol', 'Taylor'); Query OK, 1 row affected (0.08 sec)Display all records from the table using ... Read More