- 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
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
396 Views
Use DATE_FORMAT for this. Let us first create a table −mysql> create table DemoTable ( ShippingDate varchar(200) ); Query OK, 0 rows affected (0.25 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('04:58 PM 10/31/2018'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('02:30 AM 01/01/2019'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values('12:01 AM 05/03/2019'); Query OK, 1 row affected (0.06 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------------------+ | ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
75 Views
Use aggregate function MIN() along with GROUP BY for this. Here, we will display the minimum ID for NumberOfProduct . Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, NumberOfProduct int ); Query OK, 0 rows affected (0.19 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(NumberOfProduct) values(40); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(NumberOfProduct) values(40); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable(NumberOfProduct) values(60); Query OK, 1 row affected (0.07 sec) mysql> ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
517 Views
You can use GROUP_CONCAT() function from MySQL to display result as a comma separated list. Let us first create a table −mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.26 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.07 sec) mysql> ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
303 Views
To sum based on field values, use aggregate function SUM() along with CASE statement. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Price int, isValidCustomer boolean, FinalPrice int ); Query OK, 0 rows affected (0.23 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Price, isValidCustomer, FinalPrice) values(20, false, 40); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(Price, isValidCustomer, FinalPrice) values(45, true, 10); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(Price, isValidCustomer, FinalPrice) ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
450 Views
To replace apostrophe, you can use replace(). Following is the syntax −update yourTableName set yourColumnName=replace(yourColumnName, '\'', '');Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Sentence varchar(100) ); Query OK, 0 rows affected (0.17 sec)Insert some records in the table using insert command. Apostrophe is added for the sentence −mysql> insert into DemoTable(Sentence) values('Chris\'s Father'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(Sentence) values('Larry\'s Mother'); Query OK, 1 row affected (0.06 sec)Display all records from the table using select statement −mysql> select *from ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
72 Views
To order string as a number, use CAST(). Following is the syntax −select *from yourTableName ORDER BY CAST(yourColumnName AS SIGNED) DESC;Let us first create a table −mysql> create table DemoTable ( Id varchar(100) ); Query OK, 0 rows affected (0.18 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('3'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values('20'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values('34'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('21'); Query OK, 1 row ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
193 Views
You need to use OR condition along with WHERE clause. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, MonthNumber int, YearNumber int ); Query OK, 0 rows affected (0.22 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(MonthNumber, YearNumber) values(11, 2018); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(MonthNumber, YearNumber) values(3, 2019); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(MonthNumber, YearNumber) values(12, 2018); Query OK, 1 row affected (0.08 sec) mysql> insert ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
101 Views
You can use ORDER BY RIGHT() for this. Let us first create a table −mysql> create table DemoTable ( UserId varchar(100) ); Query OK, 0 rows affected (0.33 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('User1234'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values('User9874'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('User9994'); Query OK, 1 row affected (0.04 sec) mysql> insert into DemoTable values('User1211'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('User1012'); Query OK, 1 ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
164 Views
The SOUNDEX() returns a soundex string. Two strings that sound almost the same should have identical soundex stringsTo query soundex() in MySQL, you can use the below syntax −select *from yourTableName where soundex(yourValue)=soundex(yourColumnName);Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20), LastName varchar(20) ); Query OK, 0 rows affected (0.28 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName, LastName) values('Adam', 'Smith'); Query OK, 1 row affected (0.04 sec) mysql> insert into DemoTable(FirstName, LastName) values('David', 'Miller'); Query OK, 1 ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
101 Views
You can use CONCAT() function for this. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value1 varchar(10), Value2 varchar(10) ); Query OK, 0 rows affected (0.21 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value1, Value2) values('10', '345'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(Value1, Value2) values('14', '789'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(Value1, Value2) values('18', '234'); Query OK, 1 row affected (0.13 sec)Display all records from the table using ... Read More