Samual Sam has Published 2492 Articles

How to select all rows from a table except the last one in MySQL?

Samual Sam

Samual Sam

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

2K+ Views

You need to use != operator along with subquery. The syntax is as follows −select *from yourTableName where yourIdColumnName != (select max(yourIdColumnName) from yourTableName );To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table AllRecordsExceptLastOne    -> ( ... Read More

Period ofDays() method in Java

Samual Sam

Samual Sam

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

254 Views

The Period can be obtained with the given number of days using the ofDays() method in the Period class in Java. This method requires a single parameter i.e. the number of days and it returns the Period object with the given number of days.A program that demonstrates this is given ... Read More

Count boolean field values within a single MySQL query?

Samual Sam

Samual Sam

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

1K+ Views

To count boolean field values within a single query, you can use CASE statement. Let us create a demo table for our example −mysql> create table countBooleanFieldDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentFirstName varchar(20),    -> isPassed tinyint(1)    -> ); ... Read More

C++ Program to Check if a Binary Tree is a BST

Samual Sam

Samual Sam

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

753 Views

Binary Search Tree is a binary tree data structure in which we have 3 properties −The left subtree of a binary search tree of a node contains only nodes with keys lesser than the node’s key.The right subtree of a binary search tree node contains only nodes with keys greater ... Read More

Insert an element to List using ListIterator in Java

Samual Sam

Samual Sam

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

232 Views

Let us first create an ArrayList −ArrayList < Integer > arrList = new ArrayList < Integer > (); arrList.add(100); arrList.add(200); arrList.add(300); arrList.add(400); arrList.add(500);Now, create a ListIterator from the above ArrayList and insert more elements −ListIterator < Integer > iterator = arrList.listIterator(); iterator.add(1000); iterator.add(2000); iterator.add(3000);Example Live Demoimport java.util.ArrayList; import java.util.ListIterator; public class ... Read More

Create Septet Tuple in Java

Samual Sam

Samual Sam

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

82 Views

To create a Septet Tuple in Java, use the with() method.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program. If you are using Eclipse ... Read More

How to remove a java variable from current scope in JSP?

Samual Sam

Samual Sam

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

368 Views

The tag removes a variable from either a specified scope or the first scope where the variable is found (if no scope is specified). This action is not particularly helpful, but it can aid in ensuring that a JSP cleans up any scoped resources it is responsible for.AttributeThe ... Read More

Period ofYears() method in Java

Samual Sam

Samual Sam

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

139 Views

The Period can be obtained with the given number of years using the ofYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years and it returns the Period object with the given number of years.A program that demonstrates this is given ... Read More

Generate 10 random four-digit numbers in Java

Samual Sam

Samual Sam

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

4K+ Views

To generated random integer, use the Random class with nextInt. At first, create a Random object −Random rand = new Random();The Random above is a random number generator. Now, pick the random numbers one by one. We want 10 random four-digit numbers, therefore loop it until i = 1 to ... Read More

Create Pair Tuple from Array in Java

Samual Sam

Samual Sam

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

546 Views

Use the fromArray() method to create a Pair Tuple from Array.Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to import the following package −import org.javatuples.Pair;Note − Steps to download and run JavaTuples program. If you are using Eclipse ... Read More

Advertisements