- 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
Krantik Chavan has Published 308 Articles
Krantik Chavan
1K+ Views
To select first element of a comma-separated list, you can use SUBSTRING_INDEX(). Let us first create a table:mysql> create table DemoTable ( CSV_Value varchar(200) ); Query OK, 0 rows affected (0.81 sec)Following is the query to insert some records in the table using insert command. We have inserted records ... Read More
Krantik Chavan
160 Views
You can use the $size operator for internal array size in MongoDB. The syntax is as follows:db.internalArraySizeDemo.aggregate( [ { $group: { _id:yourObjectIdValue, anyFieldName: {$first: {$size: "$yourArrayName" }} ... Read More
Krantik Chavan
614 Views
In order to select particular range of values in a MySQL table, you can use WHERE clause. Let us first create a table:mysql> create table DemoTable ( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(200), CustomerAge int, isRegularCustomer bool ); Query OK, 0 rows affected ... Read More
Krantik Chavan
160 Views
To get Age using BirthDate column in a MySQL query, you can use datediff(). Let us first create a table:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, DateOfBirth date ); Query OK, 0 rows affected (1.46 sec)Following is the query to insert some records ... Read More
Krantik Chavan
1K+ Views
To perform Regex search on integer value, you need to use $where operator. The syntax is as follows:db.yourCollectionName.find({ $where: "/^yourIntegerPatternValue.*/.test(this.yourFieldName)" });To understand the above concept, let us create a collection with document. The query to create a collection with document is as follows:> db.regExpOnIntegerDemo.insertOne({"StudentId":2341234}); { "acknowledged" : true, ... Read More
Krantik Chavan
559 Views
To get the names beginning with a particular character, you need to use LIKE. Let us first create a table:mysql> create table DemoTable ( StudentFirstName varchar(20) ); Query OK, 0 rows affected (1.01 sec)Following is the query to insert some records in the table using insert command:mysql> insert into ... Read More
Krantik Chavan
1K+ Views
To convert string to 24 hour datetime format in MySQL, you can use STR_TO_DATE() method. With that use the following format for datetime as the parameter:'%Y-%m-%d %H:%i:%s'Following is the syntaxSELECT STR_TO_DATE(yourColumnName, '%Y-%m-%d %H:%i:%s') FROM yourTableName;Let us first create a table:mysql> create table DemoTable (ArrivalDate varchar(200)); Query OK, 0 rows affected ... Read More
Krantik Chavan
664 Views
If you’re using InnoDB engine, then you cannot set auto_increment value of tables to lower value. You need to change your engine from InnoDB to MyISAM.Note: The engine MyISAM allows you to set lower value. Here, we are using the same.According to the official documents:You cannot reset the counter to ... Read More
Krantik Chavan
31 Views
The total number of months for a particular Period can be obtained using the toTotalMonths() method in the Period class in Java. This method requires no parameters and it returns the total number of months in the Period in the form of a long value.A program that demonstrates this is ... Read More
Krantik Chavan
66 Views
The Period can be obtained with the given number of days, months and years using the of() method in the Period class in Java. This method requires a 3 parameters i.e. the number of days, the number of months and the number of years. Also, it returns the Period object ... Read More