- 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
382 Views
To replace, use REPLACE() function from MySQL. Let us first create a table −mysql> create table DemoTable ( Number varchar(100) ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('+916578675547'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('+918976676564'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('+919800087678'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------------+ | Number ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
87 Views
Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(100), ClientAge int ); Query OK, 0 rows affected (0.92 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ClientName, ClientAge) values('Robert', 45); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(ClientName, ClientAge) values('Mike', 55); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(ClientName, ClientAge) values('Bob', 42); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable(ClientName, ClientAge) values('Sam', 47); Query OK, 1 row affected (0.11 sec)Display all records from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
533 Views
To fetch the 2nd highest value, use ORDER BY DESC with LIMIT 1, 1. Let us first create a table −mysql> create table DemoTable ( StudentScore int ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(89); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(69); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(97); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(99); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
62 Views
For this, use IS NULL property. Let us first create a table −mysql> create table DemoTable ( EmployeeName varchar(100), EmployeeAge int ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 32); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('David', 45); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('Bob', NULL); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('Sam', 28); Query OK, 1 row affected (0.14 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)
72 Views
We will see an example and create a table wherein we have set StudentId column as AUTO_INCREMENT = 100 and used ZEROFILL as well −mysql> create table DemoTable ( StudentId int(7) ZEROFILL NOT NULL AUTO_INCREMENT, PRIMARY KEY(StudentId) )AUTO_INCREMENT=100; Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command. Now, when nothing is inserted, the value would begin from 101 (auto_increment) and rest of the values in the left would be filled with 0 since we have set ZEROFILL while creating the table above −mysql> insert into DemoTable values(); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
79 Views
Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, PlayerName varchar(100), PlayerScore int ); Query OK, 0 rows affected (0.97 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(PlayerName, PlayerScore) values('Chris', 780); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable(PlayerName, PlayerScore) values('Sam', 1100); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(PlayerName, PlayerScore) values('Mike', 900); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(PlayerName, PlayerScore) values('Bob', 890); Query OK, 1 row affected (0.15 sec) mysql> insert into ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
361 Views
To format, use DATE_FORMAT(). Let us first create a tablemysql> create table DemoTable ( LoginTime time ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('13:10'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('20:08'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values('10:55'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('16:40'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-----------+ | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
536 Views
To remove only the first word from column values, use substring(). Following is the syntax −select substring(yourColumnName, locate(' ', yourColumnName)+1) AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable ( Title text ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Java in Depth'); Query OK, 1 row affected (0.49 sec) mysql> insert into DemoTable values('C++ is an object oriented programming language'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable values('MySQL is a relational database'); Query OK, 1 row affected (0.17 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
87 Views
Let’s say the stored price is inclusive of 20% sales tax. Now, let us first create a table −mysql> create table DemoTable ( Price int ); Query OK, 0 rows affected (1.09 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values(80); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
97 Views
Let us first create a table −mysql> create table DemoTable ( Title text ); Query OK, 0 rows affected (0.39 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Introduction to MySQL'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Introduction to Java'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('Introduction to SQL'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Introduction to Python'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Introduction to SQL'); Query OK, 1 row affected (0.09 sec) ... Read More