- 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)
224 Views
Yes, we can use INTERVAL while inserting data records. Let us first create a table −mysql> create table DemoTable ( ArrivalTime datetime ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command. Here, we are using INTERVAL keyword for incrementing the date records while inserting −mysql> insert into DemoTable values(date_add(now(), interval 4 hour)); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable values(date_add('2016-01-31 10:40:50', interval 2 hour)); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(date_add('2015-05-01 12:00:00', interval 1 hour)); Query OK, 1 row affected (0.25 sec) mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
104 Views
Yes, you can give the year as a column name in MySQL table since it isn’t a reserved word. Let us first create a table −mysql> create table DemoTable ( Year int ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1995); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(2019); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(2016); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(2018); Query OK, 1 row affected (0.13 sec)Display all records from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
279 Views
To concatenate rows on the basis of boolean value in another column, use GROUP_CONCAT(). Let us first create a table. Here, we have set one of the columns “isValidUser” as BOOLEAN −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserMessage varchar(100), isValidUser boolean ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(UserMessage, isValidUser) values('Hi', true); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable(UserMessage, isValidUser) values('Hello', false); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(UserMessage, isValidUser) values('Good', ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
88 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)
124 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)
398 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)
473 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)
174 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)
242 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