
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 6705 Articles for Database

258 Views
Let us see the best way to store weekly events in MySQL. For that, first create a new table and include fields for every day as well.mysql> create table WeeklyEventDemo -> ( -> ID int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EventName varchar(20), -> Monday tinyint(1), -> Tuesday tinyint(1), -> Wednesday tinyint(1), -> Thursday tinyint(1), -> Friday tinyint(1), -> Saturday tinyint(1), -> Sunday tinyint(1), -> StartDate date, ... Read More

8K+ Views
The my.ini is in hidden folder of program data. First go to C: drive and then hidden folder of program data. From that, move to the MySQL version directory.Here is the snapshot of the C: drive −Click on C drive. The snapshot is as follows. Here, you can see the Program Data folder −Now go to MySQL under Program Data folder. The snapshot is as follows −Go to MySQL version. The snapshot is as follows −Note − Here, we are using MySQL version 8.0.12Here is the my.ini file.In order to reach the location, you can also use the following command ... Read More

256 Views
You can use LEFT JOIN to find minimum unused value in a MySQL table. Let us first create a tablemysql> create table FindValue -> ( -> SequenceNumber int -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into FindValue values(109); Query OK, 1 row affected (0.14 sec) mysql> insert into FindValue values(110); Query OK, 1 row affected (0.15 sec) mysql> insert into FindValue values(111); Query OK, 1 row affected (0.13 sec) mysql> insert into FindValue values(113); Query OK, 1 row affected (0.13 ... Read More

10K+ Views
The syntax is as follows to perform UPDATE using IF condition in MySQL −update yourTableName set yourColumnName =if(yourColumnName =yourOldValue, yourNewValue, yourColumnName);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table updateIfConditionDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20), -> UserAge int -> ); Query OK, 0 rows affected (4 min 0.59 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into updateIfConditionDemo(UserName, UserAge) values('Larry', 23); Query OK, ... Read More

6K+ Views
To GROUP BY date while using datetime, the following is the syntax −select *from yourTableName GROUP BY date(yourColumnName);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table groupByDateDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20), -> UserPostDatetime datetime -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into groupByDateDemo(UserName, UserPostDatetime) values('Larry', '2018-01-02 13:45:40'); Query OK, 1 row affected (0.18 sec) mysql> insert ... Read More

8K+ Views
To reset the primary key to 1 after deleting the data, use the following syntaxalter table yourTableName AUTO_INCREMENT=1; truncate table yourTableName;After doing the above two steps, you will get the primary key beginning from 1.To understand the above concept, let us create a table. The query to create a table is as followsmysql> create table resettingPrimaryKeyDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY -> ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into resettingPrimaryKeyDemo values(); Query OK, 1 row ... Read More

512 Views
You can use REGEXP BINARY for thisselect *from yourTableName where yourColumnName REGEXP BINARY '[A-Z]{2}';Let us first create a tablemysql> create table FindCapitalLettrsDemo -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentFirstName varchar(20) -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('JOHN'); Query OK, 1 row affected (0.24 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('Carol'); Query OK, 1 row affected (0.15 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... Read More

204 Views
Use quote() function for this. The syntax is as follows −select yourColumnName, quote(yourColumnName) from yourTableName;To understand the concept, let us create a table. The query to create a table is as follows −mysql> create table seeSpacesDemo -> ( -> spaceValue varchar(10) -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into seeSpacesDemo values(""); Query OK, 1 row affected (0.70 sec) mysql> insert into seeSpacesDemo values(" "); Query OK, 1 row affected (0.45 sec) mysql> insert into seeSpacesDemo values(" "); Query OK, 1 ... Read More

124 Views
Let us first create a demo tablemysql> create table RandomNumberDemo -> ( -> MyNumber int -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into RandomNumberDemo values(17); Query OK, 1 row affected (0.20 sec) mysql> insert into RandomNumberDemo values(18); Query OK, 1 row affected (0.12 sec) mysql> insert into RandomNumberDemo values(29); Query OK, 1 row affected (0.49 sec)Display all records from the table using select statement. The query is as follows −mysql> select *from RandomNumberDemo;The following is the output+----------+ | MyNumber | ... Read More

1K+ Views
You can use ROUND() function.The syntax is as followsSELECT ROUND(yourColumnName, yourPrecisionIntegerValue) from yourTableName;To understand the concept, let us create a table. The query to create a table is as followsmysql> create table givenPrecisionDemo -> ( -> Amount float -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into givenPrecisionDemo(Amount) values(45.678); Query OK, 1 row affected (0.12 sec) mysql> insert into givenPrecisionDemo(Amount) values(123.456); Query OK, 1 row affected (0.15 sec) mysql> insert into givenPrecisionDemo(Amount) values(245.890); Query OK, ... Read More