
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 4381 Articles for MySQL

372 Views
Let’s say the current date is 2019-09-14 8 :50 :10. Now, we want records from 00 :00 to 2019-09-14 8 :50 :10. Let us now see an example and create a table −mysql> create table DemoTable ( DueDate datetime ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-09-14'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('2019-09-14 8 :00 :10'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2019-09-14 8 :44 :00'); Query OK, 1 row affected (0.14 sec) mysql> insert ... Read More

300 Views
Let us first see an example and create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(40), StudentAge int, StudentMarks int ); Query OK, 0 rows affected (0.76 sec)Following is the query to know the database structure −mysql> show create table DemoTable;This will produce the following output −+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table ... Read More

795 Views
To exclude records, use MySQL NOT IN(). Let us first create a table −mysql> create table DemoTable ( Id int ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(2); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(3); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(4); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable values(5); Query OK, 1 row affected (0.09 sec) mysql> insert into ... Read More

187 Views
Let us first create a table −mysql> create table DemoTable ( Name varchar(40), Position int ); Query OK, 0 rows affected (1.17 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 90); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('David', 67); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('Bob', 55); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Sam', 40); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the ... Read More

151 Views
For this, use aggregate function COUNT() and GROUP BY to group those specific records for occurrences. Let us first create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentSubject varchar(40) ); Query OK, 0 rows affected (5.03 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentSubject) values('MySQL'); Query OK, 1 row affected (0.78 sec) mysql> insert into DemoTable(StudentSubject) values('Java'); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable(StudentSubject) values('MySQL'); Query OK, 1 row affected (1.12 sec) mysql> insert into DemoTable(StudentSubject) values('MongoDB'); Query OK, 1 row affected ... Read More

444 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

400 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

1K+ 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

243 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

276 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