- 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
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
197 Views
For performing mathematical operations and working with conditions, you can consider CASE statement. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FruitName varchar(100), FruitPrice int ); Query OK, 0 rows affected (0.26 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FruitName, FruitPrice) values('Orange', 250); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(FruitName, FruitPrice) values('Banana', 100); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(FruitName, FruitPrice) values('Apple', 150); Query OK, 1 row affected (0.05 sec) ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
58 Views
The variable table_type doesn’t work since this variable is deprecated as of MySQL 5.5.3. Use default_storage_engine instead. Following is the syntax −SET default_storage_engine = yourTableEngine;The table engine name may be InnoDB or MyISAM. Here, we will set engine type to MyISAM −mysql> SET default_storage_engine=MyISAM; Query OK, 0 rows affected (0.00 sec)Let us create a table.mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY ); Query OK, 0 rows affected (0.40 sec)Now check the engine type of above table −mysql> SHOW TABLE STATUS WHERE Name = 'DemoTable';This will produce the following output −+--------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | Name | Engine | ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
1K+ Views
You can use TINYINT data type in MySQL to store negative number. Following is the syntax −CREATE TABLE yourTableName ( yourColumnName TINYINT . . . . N );Let us first create a table with a column set as type TINYINT −mysql> create table DemoTable ( Number tinyint ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
463 Views
To update boolean value, you can use SET. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, isMarried boolean ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(isMarried) values(false); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(isMarried) values(true); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(isMarried) values(true); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(isMarried) values(false); Query OK, 1 row affected (0.13 sec)Display all records ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
707 Views
You can use GROUP BY along with aggregate function COUNT(). Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Size ENUM('S', 'M', 'L', 'XL') ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Size) values('L'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(Size) values('S'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Size) values('S'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable(Size) values('M'); Query OK, 1 ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
107 Views
Use SET to decrease the value and WHERE to set the condition for a specific record to be 0. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Number int ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command &minusmysql> insert into DemoTable(Number) values(10); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Number) values(20); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Number) values(1); Query OK, 1 row affected ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
943 Views
You can use group_concat() along with concat() to concatenate all values of a single column. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20) ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName) values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(FirstName) values('Larry'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(FirstName) values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(FirstName) values('Robert'); ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
256 Views
To fetch domain name by passing name in MySQL, you can use substring_index(). Let us first create a table −mysql> create table DemoTable ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserMailId varchar(200) ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(UserMailId) values('John9989@facebook.com'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(UserMailId) values('983773CS@yahoo.com'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(UserMailId) values('Chris95@gmail.com'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------+-----------------------+ | UserId | UserMailId | +--------+-----------------------+ | ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
97 Views
Use aggregate function SUM() along with OVER. Let us first create a table −mysql> create table DemoTable ( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerValue int ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CustomerValue) values(10); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(CustomerValue) values(20); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(CustomerValue) values(30); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(CustomerValue) values(40); Query OK, 1 row affected (0.14 sec)Display all records ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
227 Views
Let us first create a table −mysql> create table DemoTable ( UserId int, UserName varchar(20), UserAge int ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(UserId,UserName,UserAge) values(100,'John',25),(101,'Larry',24),(102,'Chris',22),(103,'Carol',27); Query OK, 4 rows affected (0.16 sec) Records: 4 Duplicates: 0 Warnings: 0Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------+----------+---------+ | UserId | UserName | UserAge | +--------+----------+---------+ | 100 | John | 25 | | 101 | Larry | 24 | | 102 | Chris | 22 | | 103 | Carol | 27 | +--------+----------+---------+ 4 rows in set (0.00 sec)