- 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 4378 Articles for MySQL
![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)
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
268 Views
To get possible values for set field, you can use below syntax −desc yourTableName yourSetColumnName;Let us first create a table −mysql> create table DemoTable ( Game set('Chess','Pig Dice','29 Card') ); Query OK, 0 rows affected (0.60 sec)Following is the query to get available values for set field −mysql> desc DemoTable Game;This will produce the following output −+-------+-----------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-----------------------------------+------+-----+---------+-------+ | Game | set('Chess','Pig Dice','29 Card') | YES | | NULL | | +-------+-----------------------------------+------+-----+---------+-------+ 1 row in set (0.02 sec)
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
563 Views
You can change the MySQL date format with a specific format using DATE_FORMAT(). Following is the syntax −select date_format(yourColumnName, yourFormatSpecifier) from yourTableName;Let us first create a table −mysql> create table DemoTable ( ShippingDate date ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2016-01-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2018-05-24'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('2019-12-31'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
110 Views
To set a pecific date format, you need to use DATE_FORMAT() in MySQL. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ArrivalDate date ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ArrivalDate) values('2019-01-31'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(ArrivalDate) values('2019-04-26'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(ArrivalDate) values('2019-03-01'); Query OK, 1 row affected (0.13 sec)Display all ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
344 Views
Yes, you can include a string value with spaces in ENUM type. Let us first create a table −mysql> create table DemoTable ( Size ENUM('SMALL SIZE', 'LARGE SIZE', 'XL SIZE') ); Query OK, 0 rows affected (0.65 sec)Let us check the description of table using DESC command −mysql> desc DemoTable;This will produce the following output −+-------+-------------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------------------------------------+------+-----+---------+-------+ | Size | enum('SMALL SIZE', 'LARGE SIZE', 'XL SIZE') ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
650 Views
You can use CASE statement for this. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value1 int, Value2 int ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value1, Value2) values(10, 5); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(Value1, Value2) values(20, 0); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(Value1, Value2) values(40, 10); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable(Value1, Value2) ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
111 Views
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.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Number) values(10); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Number) values(50); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(Number) values(100); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(Number) values(190); Query OK, 1 row affected (0.12 sec)Display all ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
46 Views
Use MONTH() and YEAR() for this. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ShippingDate datetime ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ShippingDate) values('2019-01-21 10:40:21'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(ShippingDate) values('2015-07-01 11:15:30'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(ShippingDate) values('2012-12-31 10:45:56'); Query OK, 1 row affected (0.14 sec)Display all records from the table ... Read More