- 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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
532 Views
Use IF() function to return null for date_format when input is null in MySQL. The syntax is as follows −SELECT IF(yourDateColumnName, date_format(yourDateColumnName, '%d/%m/%Y'), NULL) FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table returnNullWhenInputIsNullDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ShippingDate datetime -> ); Query OK, 0 rows affected (1.21 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into returnNullWhenInputIsNullDemo(ShippingDate) values('2019-01-21'); Query OK, 1 row affected ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
3K+ Views
You can use printjson() method to print to console an object in a MongoDB script. The syntax is as follows −printjson({yourFieldName”:yourValue”, ........N});You can use JSON.stringify() along with print() function. The syntax is as follows minus;print ( JSON.stringify( { {yourFieldName”:yourValue”, ........N} } ));Let us implement the above syntax to print object in Mongo script. The query is as follows −>printjson({"UserId":101, "UserName":"John", "UserCoreSuject":["Java", "MongoDB", "MySQL", "SQL Server"]});The following is the output −{ "UserId" : 101, "UserName" : "John", "UserCoreSuject" : [ "Java", "MongoDB", "MySQL", "SQL Server" ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
To query MySQL on the current week, you can use YEARWEEK() function.The syntax is as followsSELECT *FROM yourTableName WHERE YEARWEEK(yourDateColumnName) = YEARWEEK(NOW());To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table currentWeekDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20), -> UserPostDate date -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into currentWeekDemo(UserName, ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
249 Views
Use DateTime to convert PHP variable “11:00 AM: to MySQL time format.The PHP code is as follows −$phpTime = '11:00 AM'; echo('The PHP Time Format is ='); echo ($phpTime); $timeFormat = DateTime::createFromFormat( 'H:i A', $phpTime); $MySQLTimeFormat = $timeFormat->format( 'H:i:s'); echo (' '); echo('The MySQL Time Format is ='); echo ($MySQLTimeFormat);The snapshot of PHP code is as follows −Here is the output −The PHP Time Format is =11:00 AM The MySQL Time Format is =11:00:00
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
158 Views
You can use lc_messages to change MySQL error message language. The syntax is as follows −SET lc_messages = 'yourLanguage';To understand the concept, let us create a table with some error and check the error message language.Here, we have set the local message to French. Let us first create a table −mysql> create table errorMessagelanguage -> ( -> Error_MessageId int, -> Error_Message varchar(100), -> );The error message is as follows −ERROR 1064 (42000): Erreur de syntaxe près de ')' à la ligne 5Now you can set the error message to be in English language. The query is ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
114 Views
First check all the user and host from MySQL.user table with the help of select statement as shown belowmysql> select user, host from MySQL.user;The following is the output+------------------+-----------+ | user | host | +------------------+-----------+ | Bob | % | | Manish | % | | User2 | % | | mysql.infoschema | % | | mysql.session | % ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
1K+ Views
To retrieve a value from MongoDB by its key name, use the following syntax −db.yourCollectionName.find({}, {"yourFieldName":1}).pretty();To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.retrieveValueFromAKeyDemo.insertOne({"CustomerName":"Larry", "CustomerAge":21, "CustomerCountryName":"US"}); { "acknowledged" : true, "insertedId" : ObjectId("5c9163b5a56efcc0f9e69048") } > db.retrieveValueFromAKeyDemo.insertOne({"CustomerName":"Chris", "CustomerAge":24, "CustomerCountryName":"AUS"}); { "acknowledged" : true, "insertedId" : ObjectId("5c9163c4a56efcc0f9e69049") } > db.retrieveValueFromAKeyDemo.insertOne({"CustomerName":"Mike", "CustomerAge":26, "CustomerCountryName":"UK"}); { "acknowledged" : true, "insertedId" : ObjectId("5c9163d3a56efcc0f9e6904a") }Display all documents from a collection with the help of find() method. The query is as follows −> db.retrieveValueFromAKeyDemo.find().pretty();The ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
184 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
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
6K+ 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
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
163 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