- 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 6703 Articles for Database
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
90 Views
To ORDER BY letters, use ORDER BY SUBSTRING(). Let us first create a table −mysql> create table DemoTable ( Id varchar(100) ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('456 John Smith'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('897 Adam Smith'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('1009 Bob Smith'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+----------------+ | Id ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
125 Views
To fetch the maximum value, use any of the below-given syntaxes −select max(yourColumnName) from yourTableName; OR select *from yourTableName order by yourColumnName desc limit 1;Let us first create a table −mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.84 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(87); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(56); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(77); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
402 Views
For alphabetic search, use the REGEX in MySQL. Here, let’s say we are searching for records beginning with A, B or C. The syntax to use REGEXP for the same purpose is as follows −select *from yourTableName where yourColumnName REGEXP '^[ABC]';Let us first create a table −mysql> create table DemoTable ( Name varchar(100) ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Mike'); Query ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
475 Views
TRIM is used to remove leading and trailing spaces. Let us first create a table −mysql> create table DemoTable ( StudentName varchar(100) ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command. Here, we have inserted records with leading and trailing whitespaces −mysql> insert into DemoTable values(' Adam Smith '); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(' David Miller '); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(' Chris Brown '); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(' Carol ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
4K+ Views
Let us first create a table −mysql> create table DemoTable ( DueDate date ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2018-10-01'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('2016-12-31'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2019-07-02'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('2015-01-12'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('2019-04-26'); Query OK, 1 row affected (0.13 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)
178 Views
Let us first create a table −mysql> create table DemoTable ( AdmissionDate varchar(100) ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Sunday, 11 August 2019'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Friday, 18 October 2019'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Thursday, 18 July 2019'); Query OK, 1 row affected (0.23 sec)Display all records from the table using select statement −mysql> select *from DemoTable ;This will produce the following output −+-------------------------+ | AdmissionDate ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
244 Views
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.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value1, Value2) values(100, 150); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Value1, Value2) values(500, 1000); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(Value1, Value2) values(15000, 18000); Query OK, 1 row affected (0.13 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)
384 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)
535 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