- 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
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
155 Views
You can use the following syntax if your column has varchar data type −select yourColumnName FROM yourTableName ORDER BY yourColumnName +0 DESC;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table selectOrderdemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100), -> RankNumber varchar(100) -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into selectOrderdemo(Name, RankNumber) values('Larry', -100); Query OK, 1 row affected (0.23 ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
To delete all rows older than 5 days, you can use the following syntax −delete from yourTableName where datediff(now(), yourTableName.yourDateColumnName) > 5;Note − Let’s say the current date is 2019-03-10.To understand the concept, let us create a table. The query to create a table is as follows −mysql> create table deleteRowsOlderThan5Demo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100), -> Post_Date date -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into deleteRowsOlderThan5Demo(Name, Post_Date) ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
689 Views
To remove hyphens using MySQL update, you can use replace() function. The syntax is as follows −update yourTableName set yourColumnName=replace(yourColumnName, '-', '' );To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table removeHyphensDemo -> ( -> userId varchar(100) -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into removeHyphensDemo values('John-123-456'); Query OK, 1 row affected (0.22 sec) mysql> insert into removeHyphensDemo values('Carol-9999-7777-66555'); Query OK, 1 row affected (0.19 sec) ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
To count the top 10 most occurring values in a column in MySQL, The syntax is as follows −SELECT yourColumnName, count(*) FROM yourTableName GROUP BY yourColumnName ORDER BY count(*) DESC LIMIT 10;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table countTop10Demo -> ( -> Value int -> ); Query OK, 0 rows affected (0.74 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into countTop10Demo values(10); Query OK, 1 row affected (0.12 sec) ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
To select dates in 30-day range, you can use arithmetic operation - with interval.The syntax is as follows −select *from yourTableName where yourDateColumnName > NOW() - INTERVAL 30 DAY and yourDateColumnName < NOW() + INTERVAL 30 DAY;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table selectDatesDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ArrivalDate datetime -> ); Query OK, 0 rows affected (0.77 sec)Now you can insert some records in the table using insert command. The query is as ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
96 Views
Let us first create a demo table −mysql> create table selectPerson -> ( -> PersonId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> PersonName varchar(20), -> PersonFavouriteFruit varchar(60) -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into selectPerson(PersonName, PersonFavouriteFruit) values('John', 'Banana'); Query OK, 1 row affected (0.14 sec) mysql> insert into selectPerson(PersonName, PersonFavouriteFruit) values('John', 'Blackberry'); Query OK, 1 row affected (0.12 sec) mysql> insert into selectPerson(PersonName, PersonFavouriteFruit) values('John', 'Blueberry'); Query OK, 1 row affected (0.12 sec) mysql> insert into selectPerson(PersonName, ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
43 Views
To test, use the sleep() function.Case 1 −The syntax is as follows −SELECT yourColumnName+sleep(yourIntegerValue) FROM yourTableName GROUP BY yourColumnName+sleep(yourIntegerValue);;Case 2 − You can use another syntax which is as follows −SELECT yourColumnName+sleep(yourIntegerValue) As anyAliasName FROM yourTableName GROUP BY yourAliasName;To understand the above syntaxes, let us create a table. The query to create a table is as follows −mysql> create table sleepDemo -> ( -> value int -> ); Query OK, 0 rows affected (1.25 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into sleepDemo values(40); Query OK, 1 row ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
No, you cannot give the same name for view and table in MySQL.Let us first create a demo table −mysql> create table view_Table_Demo -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.80 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into view_Table_Demo values(100, 'Larry'); Query OK, 1 row affected (0.17 sec) mysql> insert into view_Table_Demo values(101, 'Mike'); Query OK, 1 row affected (0.20 sec) mysql> insert into view_Table_Demo values(102, 'Sam'); Query OK, 1 row affected (0.14 sec)Display all ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
672 Views
You can use SET command, but SET OPTIOn deprecated. Therefore, use SET SQL_SELECT_LIMIT.The syntax is as follows −SET SQL_SELECT_LIMIT=yourIntegerValue;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table MySQLSelectDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY -> ); Query OK, 0 rows affected (0.99 sec)Insert some records in the table using insert command. The query is as follows −mysql> INSERT INTO MySQLSelectDemo VALUES(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ... Read More
![Naveen Singh](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
22K+ Views
Use the delete command to delete blank rows in MySQL.The syntax is as followsdelete from yourTableName where yourColumnName=' ' OR yourColumnName IS NULL;The above syntax will delete blank rows as well as NULL row.To understand the concept, let us create a table.The query to create a table is as followsmysql> create table deleteRowDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into deleteRowDemo(StudentName) values('John'); Query OK, 1 row affected ... Read More