- 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)
80 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20), -> Amount int -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 200); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Chris', 150); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Mike', 500); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('John', 350); Query OK, 1 row affected (0.18 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)
878 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(101, 'Bob'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(102, 'David'); Query OK, 1 row affected (0.18 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)
1K+ Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20), -> Age int, -> CountryName varchar(10) -> ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris', 34, 'AUS'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(101, 'Chris', 31, 'US'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(102, 'David', 25, 'UK'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(103, 'Carol', 28, 'AUS'); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
109 Views
To implement a query like MySQL IN(), you need to use COUNT(), IF() along with LIKE operator. Let us first create a table −mysql> create table DemoTable -> ( -> Subject varchar(80) -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('MySQLMongoDB'); Query OK, 1 row affected (0.86 sec) mysql> insert into DemoTable values('MySQL'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('JavaMySQL'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('MongoDB'); Query OK, 1 row affected (0.20 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
361 Views
For this, you can use COALESCE(). For the maximum value, use GREATEST() in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Value1 int, -> Value2 int, -> Value3 int -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(NULL, 80, 76); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(NULL, NULL, 100); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(56, NULL, 45); Query OK, 1 row affected (0.20 sec) mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
159 Views
To format records, use FORMAT(). Let us first create a table −mysql> create table DemoTable -> ( -> Price decimal(10, 4), -> Rate decimal(10, 4) -> ); Query OK, 0 rows affected (0.96 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1000, 10.2); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(2000, 20.4); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(100, 5); Query OK, 1 row affected (0.16 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
336 Views
To work with strings containing dots, and display records beginning with a specific number, you need to use REGEXP. Let us first create a table −mysql> create table DemoTable -> ( -> GameReleaseVersion varchar(20) -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('19.6'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('18.4'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('17.6'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('19.5'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
575 Views
For this, use the below syntax −select * from yourTableName where yourColumnName < DATE_ADD(CURDATE(), INTERVAL 2 WEEK);Note: The current date is as follows −mysql> select curdate(); +------------+ | curdate() | +------------+ | 2019-10-20 | +------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable1607 -> ( -> ShippingDate date -> ) -> ; Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1607 values('2019-10-20'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1607 values('2019-11-04'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
99 Views
Let us first create a table −mysql> create table DemoTable1606 -> ( -> Value int -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1606 values(5); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1606 values(10); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select * from DemoTable1606;This will produce the following output −+-------+ | Value | +-------+ | 5 | | 10 | +-------+ 2 rows in set (0.00 sec)Here is the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
155 Views
To set conditions in stored procedure, use the below syntax − if yourCondition then yourStatement1; else yourStatement2'; end if ; end //Let us implement the above syntax in order to correct missing semicolon in stored procedure −mysql> delimiter // mysql> create procedure Test_Demo(In inputValue int) -> BEGIN -> if inputValue=10 then -> select 'You have won 100$'; -> else -> select 'Sorry !!!'; -> end if ; -> end -> // Query OK, 0 rows affected (0.20 ... Read More