- 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)
128 Views
You can use ORDER BY STR_TO_DATE(). Let us first create a table −mysql> create table DemoTable -> ( -> DueTime varchar(20) -> ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('7:30AM'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('9:00PM'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('11:00PM'); 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−+---------+ | DueTime | +---------+ | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
113 Views
To round number, use MySQL ROUND(). Let us first create a table −mysql> create table DemoTable -> ( -> Amount DECIMAL(10, 4) -> ); Query OK, 0 rows affected (1.18 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100.578); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(1000.458); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(980.89); 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−+-----------+ | Amount | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
251 Views
Let us first create a table −mysql> create table DemoTable -> ( -> UserName varchar(20), -> UserType ENUM('New User', 'Registered User') -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 'New User'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('David', 'New User'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('Mike', 'Registered User'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('Sam', 'New User'); Query OK, 1 row affected (0.10 sec)Display all records ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
544 Views
To sum, use the aggregate function SUM(). With that, group using MySQL GROUP BY. Let us first create a table −mysql> create table DemoTable -> ( -> ProductName varchar(20), -> ProductQuantity int, -> ProductPrice int -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Product-1', 2, 50); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('Product-2', 3, 80); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Product-2', 4, 100); Query OK, 1 row affected (0.11 sec) mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
243 Views
Yes, we can set a single value with IN() in MySQL. Let us first create a table−mysql> create table DemoTable -> ( -> FirstName varchar(20) -> ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Mike'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Bob'); Query OK, 1 row affected (0.08 sec)Display all records from the table using select ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
194 Views
Yes, we can change the order of columns. This can be done using ALTER command and AFTER to set the new order of an individual column. Let us first create a table −mysql> create table DemoTable -> ( -> `Student_Key_Age` int, -> `Student_Key_Name` varchar(20), -> `Student_Key_CountryName` varchar(20) -> ); Query OK, 0 rows affected (0.64 sec)Following is the query to alter order of columns −mysql> alter table DemoTable modify column `Student_Key_Age` int after `Student_Key_Name`; Query OK, 0 rows affected (1.15 sec) Records: 0 Duplicates: 0 Warnings: 0Let us check the table description once again −mysql> ... 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 DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> StudentMarks int, -> Status varchar(20) -> ); Query OK, 0 rows affected (0.97 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentName, StudentMarks) values('Chris', 79); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(StudentName, StudentMarks) values('David', 59); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(StudentName, StudentMarks) values('Bob', 60); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(StudentName, StudentMarks) values('Mike', ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
233 Views
To perform custom sorting in MySQL, use ORDER BY FIELD(). Let us first create a table −mysql> create table DemoTable -> ( -> Id int -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command:mysql> insert into DemoTable values(101); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(103); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(102); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(105); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
294 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.93 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(101, 'Chris'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values(102, 'David'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(103, 'Robert'); 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 following output−+------+--------+ | Id | Name ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
Let us first create a table −mysql> create table DemoTable -> ( -> EmailAddress varchar(20), -> Score int -> ); Query OK, 0 rows affected (1.05 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris@gmail.com', 67); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('Robert@gmail.com', 57); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David@gmail.com', 98); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+------------------+-------+ | EmailAddress ... Read More