- 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 6702 Articles for Database
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
342 Views
To find a match from records, use MySQL IN(). Let us first create a table −mysql> create table DemoTable ( Id int, FirstName varchar(20), Gender ENUM('Male', 'Female') ); Query OK, 0 rows affected (1.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1, 'Chris', 'Male'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable values(10, 'Emma', 'Female'); Query OK, 1 row affected (1.88 sec) mysql> insert into DemoTable values(9, 'Emma', 'Male'); Query OK, 1 row affected (0.70 sec) mysql> insert into DemoTable values(11, 'Isabella', 'Female'); Query OK, 1 row affected ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
319 Views
For this, use REGEXP. For example, characters J, A, V and A. Let us first create a table −mysql> create table DemoTable ( Value varchar(50) ); Query OK, 0 rows affected (3.92 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('XYSJGHAKLMVDFFSA'); Query OK, 1 row affected (0.67 sec) mysql> insert into DemoTable values('PQRSTJAVAL'); Query OK, 1 row affected (0.58 sec) mysql> insert into DemoTable values('SJATUVAK'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('JSTUVA'); Query OK, 1 row affected (0.32 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)
927 Views
For this, you can use COUNT() along with CASE STATEMENT. Let us first create a table −mysql> create table DemoTable ( Score int ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.77 sec) mysql> insert into DemoTable values(48); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(59); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(33); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(38); Query OK, 1 row affected (0.09 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
161 Views
For this, use STR_TO_DATE(). Let us first create a table −mysql> create table DemoTable ( DueDate varchar(60) ) ; Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('12-AUG-2016'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('14-AUG-2018'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('24-AUG-2012'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('14-AUG-2012'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
221 Views
For this, you can use GROUP_CONCAT() along with GROUP BY clause. Both are used to group concat duplicates and display in a single line. Let us first create a table −mysql> create table DemoTable ( StudentFavouriteSubject varchar(40), StudentName varchar(40) ) ; Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('MySQL', 'Chris'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('MongoDB', 'Bob'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('MySQL', 'Sam'); Query OK, 1 row affected (0.10 sec) mysql> insert into ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
223 Views
Yes, you can search for particular numbers using the MySQL FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable ( ListOfNumbers varchar(100) ); Query OK, 0 rows affected (1.24 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('784, 746, 894, 344'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('456, 322, 333, 456'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('654, 785, 678, 456'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable values('123, 676, 847, 785'); Query OK, 1 row affected (0.34 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
84 Views
For this, use GROUP_CONCAT(). For only 1 values, work with MySQL WHERE clause. Let us first create a table −mysql> create table DemoTable ( PlayerName varchar(40), PlayerStatus tinyint(1) ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 1); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('David', 0); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Sam', 1); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('Carol', 1); Query OK, 1 row affected (0.12 sec) mysql> insert ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
127 Views
The easiest way to achieve this is by using the MySQL SUBSTRING_INDEX() function. Let us first create a table −mysql> create table DemoTable ( ZipCode varchar(50) ); Query OK, 0 rows affected (2.02 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('52533-909'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('12345-674'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values('89893-890'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('AAAAA-783'); Query OK, 1 row affected (0.25 sec)Display all records from the table using select statement −mysql> ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
Use UNION to select from two tables. Let us first create a table −mysql> create table DemoTable1 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20) ); Query OK, 0 rows affected (0.90 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(FirstName) values('Chris') ; Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1(FirstName) values('Adam'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1(FirstName) values('Sam'); Query OK, 1 row affected (0.16 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;This will produce the following output −+----+-----------+ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
416 Views
For the lowest values in a MySQL column, use the MIN() method and for highest, use the MAX() method. Let us first create a table −mysql> create table DemoTable ( CustomerName varchar(20), ProductAmount int ) ; Query OK, 0 rows affected (1.03 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 3599); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David', 7843); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Mike', 97474); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('Bob', 65884); Query OK, ... Read More