- 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
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
262 Views
Let us first get the current date using CURDATE(). The current date is as follows −mysql> select CURDATE(); +------------+ | CURDATE() | +------------+ | 2019-06-09 | +------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ShippingDate date -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command. While inserting, we have used date_sub to get the previous day −mysql> insert into DemoTable(ShippingDate) values(date_sub(CURDATE(), interval 1 day)); Query OK, 1 row ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
225 Views
For this, you can use CREATE TABLE AS SELECT statement. Let us first create a table −mysql> create table DemoTable1 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CountryName varchar(20) -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(CountryName) values('US'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1(CountryName) values('UK'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable1(CountryName) values('AUS'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1(CountryName) values('UK'); Query OK, ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
87 Views
To return the first n letters, use the LEFT() function. Following is the syntax −select left(yourColumnName, yourValue) from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CourseTitle text -> ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CourseTitle) values('Java with Spring and Hibernate framework'); Query OK, 1 row affected (0.43 sec) mysql> insert into DemoTable(CourseTitle) values('Python Web Development'); Query OK, 1 row affected (0.22 sec)Display all records from the table using ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
125 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Age int -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Age) values('John', 21); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(Name, Age) values(Null, 20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Name, Age) values('David', 23); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(Name, Age) values('Carol', null); ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
273 Views
For this, use the aggregate function SUM(). Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> € int -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(€) values(10); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(€) values(200); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(€) values(190); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
195 Views
For this, you can use the mid() function. Following is the syntax −select mid(yourColumnName, yourPositionToStart, yourEndValue) as anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('My best framework is Spring and Hibernate'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+-------------------------------------------+ | Title ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
250 Views
For string matching, use LIKE operator. Let us first create a table −mysql> create table DemoTable -> ( -> MonthName varchar(100) -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('JFMA'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('JMA'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JDN'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JFOSA'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
1K+ Views
For this, you can use subquery. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('John Smith'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Name) values('David Miller'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(Name) values('Chris Brown'); Query OK, 1 row affected (0.22 sec)Display all records from the table using select statement −mysql> ... Read More
![Rama Giri](https://www.tutorialspoint.com/assets/profiles/13881/profile/60_68188-1512710896.jpg)
115 Views
Let us first create a table −mysql> create table DemoTable -> ( -> status int -> ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.14 sec) ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
88 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (1.32 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('JOhn'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('CHRIS'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('DAVID'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('RObert'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+--------+ | Name ... Read More