Ankith Reddy has Published 1132 Articles

Find out if a varchar contains a percent sign in MySQL?

Ankith Reddy

Ankith Reddy

Updated on 30-Jun-2020 07:31:59

287 Views

To find out a varchar contains a percent sign in MySQL, you can use LIKE operator. The syntax is as follows −SELECT * FROM yourTableName WHERE yourColumnName like '%|%%' escape '|';To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> ... Read More

MySQL get hash value for each row?

Ankith Reddy

Ankith Reddy

Updated on 30-Jun-2020 07:24:41

2K+ Views

Get hash value of each row using MD5() function from MySQL. The syntax is as follows −SELECT MD5(CONCAT(yourColumnName1, yourColumnName2, yourColumnName3, .......N)) as anyVariableName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table getHashValueForEachRow    -> ( ... Read More

MySQL BETWEEN without endpoints?

Ankith Reddy

Ankith Reddy

Updated on 30-Jun-2020 07:01:10

134 Views

If you do not want to include the end value in between, then use the following syntax −SELECT * FROM yourTableName WHERE yourColumnName BETWEEN yourStartingValue and yourEndingValue and    yourColumnName not in (yourEndingValue );To understand the above syntax, let us create a table. The query to create a table is ... Read More

MySQL - SELECT … WHERE id IN (..) order with particular column?

Ankith Reddy

Ankith Reddy

Updated on 30-Jun-2020 06:42:32

4K+ Views

You can SELECT ….WHERE id IN(..) using field() function to order with any column. The syntax is as follows −SELECT *FROM yourTableName WHERE yourColumnName IN(‘value1’, ’value2’, .......N) ORDER BY FIELD(yourColumnName, value1’, ’value2’, .......N);To understand the above syntax, let us create a table −mysql> create table SelectOrderbyField    -> (   ... Read More

How to update two columns in a MySQL database?

Ankith Reddy

Ankith Reddy

Updated on 30-Jun-2020 06:32:46

338 Views

You can update two columns using SET command separated with comma(, ). The syntax is as follows −UPDATE yourTableName SET yourColumnName1 = ’yourValue1’, yourColumnName2 = ’yourValue2’ where yourCondition;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table StudentInformations ... Read More

Find max and second max salary for a MySQL Employee table?

Ankith Reddy

Ankith Reddy

Updated on 30-Jun-2020 06:20:27

330 Views

You can get max and second max salary from an Employee table using LIMIT OFFSET. The syntax is as follows −SELECT yourColumnName1, yourColumnName2, ....N from yourTableName ORDER BY yourColumnName desc limit 2 offset 0;To understand the above syntax, let us create a table. The query to create a table is ... Read More

Get current time and date on Android

Ankith Reddy

Ankith Reddy

Updated on 30-Jun-2020 05:28:09

9K+ Views

As per Oracle documentation, SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. In this example, we have imported simple date format class from java as shown below -import java.text.SimpleDateFormat; import java.util.Date;Step 1 − Create a new project in Android Studio, go to File ⇒ ... Read More

Loop through a HashMap using an Iterator in Java

Ankith Reddy

Ankith Reddy

Updated on 29-Jun-2020 13:55:50

157 Views

An Iterator can be used to loop through a HashMap. The method hasNext( ) returns true if there are more elements in HashMap and false otherwise. The method next( ) returns the next key element in the HashMap and throws the exception NoSuchElementException if there is no next element.A program ... Read More

Iterate through a LinkedList in reverse direction using a ListIterator in Java

Ankith Reddy

Ankith Reddy

Updated on 29-Jun-2020 13:49:56

687 Views

A ListIterator can be used to traverse the elements in the forward direction as well as the reverse direction in a LinkedList. The method hasPrevious( ) in ListIterator returns true if there are more elements in the LinkedList while traversing in the reverse direction and false otherwise. The method previous( ... Read More

Iterate through elements of a LinkedList using a ListIterator in Java

Ankith Reddy

Ankith Reddy

Updated on 29-Jun-2020 13:46:41

167 Views

A ListIterator can be used to traverse the elements in the forward direction as well as the reverse direction in a LinkedList.The method hasNext( ) in ListIterator returns true if there are more elements in the LinkedList while traversing in the forward direction and false otherwise. The method next( ) ... Read More

Previous 1 ... 3 4 5 6 7 ... 114 Next
Advertisements