- 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)
229 Views
Let us first create a table −mysql> create table DemoTable1605 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> StudentCountryName varchar(20) -> ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1605(StudentName, StudentCountryName) values('Adam', 'AUS'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1605(StudentName, StudentCountryName) values('John', 'US'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1605(StudentName, StudentCountryName) values('Bob', 'UK'); Query OK, 1 row affected (0.11 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)
3K+ Views
To convert string to timestamp format, use STR_TO_DATE() along with DATE_FORMAT(). Let us first create a table −mysql> create table DemoTable1602 -> ( -> ReportingDate varchar(40) -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1602 values('Wed Oct 02 16:10:45 IST 2019'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1602 values('Fri May 31 13:00:10 IST 2019'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1602 values('Mon Dec 31 14:20:00 IST 2018'); Query OK, 1 row affected (0.23 sec)Display all records from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
For this, you can use IF() along with UPDATE command. Let us first create a table −mysql> create table DemoTable1601 -> ( -> FirstName varchar(20) , -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1601 values('John', 'Doe'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1601 values('Adam', ''); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1601 values('David', 'Miller'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1601 values('Chris', ''); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
440 Views
Yes, using the below syntax −select * from information_schema.tables where table_name=yourTableName;Let us first create a table −mysql> create table DemoTable1600 -> ( -> StudentId int, -> StudentFirstName varchar(20) -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1600 values(100, 'Bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1600 values(101, 'David'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1600 values(102, 'Carol'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement −mysql> select * from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
352 Views
To select by month, use MONTH() function. Let us first create a table −mysql> create table DemoTable1599 -> ( -> Shippingdate datetime -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1599 values('2019-10-21'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable1599 values('2018-12-12'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable1599 values('2015-11-21'); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable1599 values('2017-12-31'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1599 values('2018-12-26'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
177 Views
For this, you can use UNIQUE constraint on one or more columns −alter table yourTablleName add unique(yourColumnName1, yourColumnName2, ...N);Let us first create a table −mysql> create table DemoTable1598 -> ( -> EmployeeId int, -> EmployeeName varchar(20), -> EmployeeCountryName varchar(20) -> ); Query OK, 0 rows affected (0.52 sec)Here is the query to implement UNIQUE on varchar columns −mysql> alter table DemoTable1598 add unique(EmployeeName, EmployeeCountryName); Query OK, 0 rows affected (0.55 sec) Records: 0 Duplicates: 0 Warnings: 0Insert some records in the table using insert command −mysql> insert into DemoTable1598 values(101, 'Adam', 'AUS'); Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
992 Views
Let us first create a table −mysql> create table DemoTable1597 -> ( -> Marks int -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1597 values(45); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1597 values(59); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1597 values(43); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1597 values(85); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1597 values(89); Query OK, 1 row affected (0.12 sec)Display all records from the table ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
3K+ Views
The rank is a MySQL reserved word defined in MySQL version 8.0.2. Therefore, you cannot use rank as a column name. You need to use backticks around the rank.Let us first check the MySQL version we are working on. Here, I am using MySQL version 8.0.12 −mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.12 | +-----------+ 1 row in set (0.00 sec)The issues by using “rank” as column name are as follows −mysql> create table DemoTable1596 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> rank int ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
139 Views
For this, use Regular Expression in MySQL as in the below syntax −select * from yourTableName where yourColumnName regexp '\land[\land ]+[ ]+[\land ]+$';The above query will work when the two words are separated by a space. Let us first create a table −mysql> create table DemoTable1412 -> ( -> Name varchar(40) -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1412 values('John Adam Carol'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1412 values('Mike Sam'); Query OK, 1 row affected (0.15 sec) mysql> insert ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
481 Views
To call stored procedures within a stored procedure, the syntax is as follows −If yourInputValue > 100 then call yourProcedureName1(); else call yourProcedureName2(); end If ; ENDLet us implement the above syntax. In order to implement the above concept, let us create a stored procedure −mysql> delimiter // mysql> create procedure Hello_Stored_Procedure() -> BEGIN -> select 'Hello World!!!'; -> END -> // Query OK, 0 rows affected (0.18 sec)The query to create the second stored procedure is as follows −mysql> create procedure Hi_Stored_Procedure() -> BEGIN -> ... Read More