Krantik Chavan has Published 278 Articles

LocalDate getDayOfYear() method in Java

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

500 Views

The day of the year for a particular LocalDate can be obtained using the getDayOfYear() method in the LocalDate class in Java. This method requires no parameters and it returns the day of the year which can be in the range of 1 to 365 and also 366 for leap ... Read More

Is it possible to make a case-insensitive query in MongoDB?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

386 Views

Yes, you can use regexp to make a case-insensitive query in MongoDB. The syntax is as follows:db.yourCollectionName.find({"yourFieldName":/^yourvalue$/i});To understand the above syntax, let us create a collection with some documents. The query to create a collection with documents is as follows:> db.caseInsensitiveDemo.insertOne({"Name":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6d7a67f2db199c1278e7ef") ... Read More

Update field in exact element array in MongoDB?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

283 Views

You can update the in exact element array in MongoDB with the help of below statement. The syntax is as follows:{"yourArrayDocumentName.$.yourNestedArrayDocument.yourPosition":"yourValue"}});To understand the above syntax, let us create a collection with some documents. The query to create a collection with document is as follows:> db.updateExactField.insertOne({"ActorId":1, "ActorDetails":[{"ActorName":"Johnny Depp", "MovieList": ["The Tourist", ... Read More

Find document with array that contains a specific value in MongoDB

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

792 Views

You can use find() method to find document with array that contains a specific value. The syntax is as follows:db.yourCollectionName.find({"yourArrayFieldName":"yourValue"}, .......N).pretty();To understand the above syntax, let us create a collection with documents. The query to create a collection with documents is as follows:>db.findSpecificValue.insertOne({"StudentId":1, "StudentName":"Larry", "FavouriteSubject":["C", "C++", "Java"]}); {    "acknowledged" ... Read More

What are Lob Data Types? What are the restrictions on these datatypes in JDBC?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

201 Views

A BLOB is binary large object that can hold a variable amount of data with a maximum length of 65535 charactersThese are used to store large amounts of binary data, such as images or other types of files.A CLOB stands for Character Large Object in general, an SQL Clob is ... Read More

Get the count of only unique rows in a MySQL column?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

211 Views

In MySQL, COUNT() will display the number of rows. DISTINCT is used to ignore duplicate rows and get the count of only unique rows.Let us first create a table:mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(10) ); Query OK, 0 rows affected ... Read More

How to remove array element in MongoDB?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

835 Views

To remove array element in MongoDB, you can use $pull and $in operator. The syntax is as follows:db.yourCollectionName.update({},    {$pull:{yourFirstArrayName:{$in:["yourValue"]}, yourSecondArrayName:"yourValue"}},    {multi:true} );To understand the above syntax, let us create a collection with document. The query to create a collection with document is as follows:>db.removeArrayElement.insertOne({"StudentName":"Larry", "StudentCoreSubject":["MongoD B", "MySQL", "SQL ... Read More

How to handle date in JDBC?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

2K+ Views

You can insert date values in SQL using the date datatype, The java.sql.Date class maps to the SQL DATE type.The PreparedStatement interface provides a method named setDate(). Using this you can insert date into a table. This method accepts two parameters −An integer representing the parameter index of the place ... Read More

Can I use SUM() with IF() in MySQL?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

274 Views

Yes, you can use SUM() with IF() in MySQL. Let us first create a demo table:mysql> create table DemoTable (    Value int,    Value2 int ); Query OK, 0 rows affected (0.51 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable ... Read More

Can we use backticks with column value in MySQL?

Krantik Chavan

Krantik Chavan

Updated on 30-Jul-2019 22:30:25

263 Views

You cannot use backticks with column value. For this, use only table name or column name. If you use backtick with column value then MySQL will give the following error message:ERROR 1054 (42S22): Unknown column '191.23.41.10' in 'where clause'Let us first create a table:mysql> create table DemoTable6 (    SystemIPAddress ... Read More

Advertisements