George John has Published 1081 Articles

MySQL query to select one specific row and another random row?

George John

George John

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

212 Views

To select one specific row and another random row, you can use ORDER BY and RAND(). Let us first create a sample table:mysql> create table oneSpecificRowAndOtherRandom    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(20)    -> ); Query OK, 0 rows affected ... Read More

IntStream anyMatch() method in Java

George John

George John

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

621 Views

The anyMatch() method in the IntStream class in Java returns whether any elements of this stream match the provided predicate.The syntax is as followsboolean anyMatch(IntPredicate predicate)To work with the IntStream class in Java, import the following packageimport java.util.stream.IntStream;Here, the predicate parameter is a stateless predicate to apply to elements of ... Read More

DoubleStream generate() method in Java

George John

George John

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

190 Views

The generate() method of the DoubleStream class returns an infinite sequential unordered stream where each element is generated by the provided DoubleSupplier.The syntax is as followsstatic DoubleStream generate(DoubleSupplier s)Here, the parameter s is the DoubleSupplier for generated elements. The DoubleSupplier is a supplier of double-valued results. To use the DoubleStream ... Read More

Does MySQL converts bool to tinyint(1) internally?

George John

George John

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

1K+ Views

Yes, MySQL internally convert bool to tinyint(1) because tinyint is the smallest integer data type.You can also say the bool is synonym for tinyint(1). Let us first create a sample table:mysql> create table boolToTinyIntDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ... Read More

8212 Non-Programmable 8-Bit I/O Port

George John

George John

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

797 Views

There are two types of Input Output ports. They are Programmable Input Output ports and Non-Programmable Input Output ports. Since the functions of Programmable Input Output ports changed by software they became more popular. We don’t need to change the wiring rather the hardware of the I/O port to change ... Read More

MongoDB query to return only embedded document?

George John

George John

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

422 Views

It is not possible to return only embedded document. However, it will return all the documents from a collection. Let us first implement the following query to create a collection with documents>db.queryToEmbeddedDocument.insertOne({"UserName":"Larry", "PostDetails":[{"UserMessage":"Hello", "UserLikes":8}, {"UserMessage":"Hi", "UserLikes":6}, {"UserMessage":"Good Morning", "UserLikes":12}, {"UserMessage":"Awesome", "UserLikes":4}]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c988a9f330fd0aa0d2fe4bd") ... Read More

How to declare a variable correctly in a MySQLProcedure?

George John

George John

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

208 Views

The variable declaration must be between BEGIN and END. Under BEGIN and END, the first statement must be declaration of variable. After that you can include insert, select, etc.Let us now see an example. Here, the variable name is “output”:mysql> DELIMITER // mysql> CREATE PROCEDURE showVariablesValue() -> ... Read More

How to use “OR” condition in MySQL CASE expression?

George John

George John

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

196 Views

Set the same condition like “OR” in a MySQL CASE expression. Let us first create a sample table.Following is the querymysql> create table caseOrConditionDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100),    -> Score int    -> ); Query OK, 0 ... Read More

Dangling, Void, Null and Wild Pointers in C++

George John

George John

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

3K+ Views

Dangling pointerDangling pointer is a pointer pointing to a memory location that has been freed (or deleted). There are different ways where Pointer acts as dangling pointerFunction CallThe pointer pointing to local variable becomes dangling when local variable is not static.int *show(void) {    int n = 76; /* ... ... Read More

How to fix the incorrect datetime value while inserting in a MySQL table?

George John

George John

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

23K+ Views

To avoid the incorrect datetime value error, you can use the STR_TO_DATE() method.As we know the datetime format is YYYY-MM-DD and if you won’t insert in the same format, the error would get generated.Let us see what actually lead to this error. For this, let us create a new table. ... Read More

Advertisements