Arjun Thakur has Published 1025 Articles

Convert dd/mm/yyyy string to Unix timestamp in MySQL?

Arjun Thakur

Arjun Thakur

Updated on 30-Jun-2020 07:25:47

516 Views

Convert dd/mm/yyyy string to Unix timestamp with the help of UNIX_TIMESTAMP(). The syntax is as follows −SELECT UNIX_TIMESTAMP(STR_TO_DATE(yourColumnName, '%d/%m/%Y')) 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 ConvertddmmyyyyInUnixTimeStamp    -> (    -> ... Read More

How can I update the boolean values in MySQL?

Arjun Thakur

Arjun Thakur

Updated on 30-Jun-2020 07:14:49

15K+ Views

You can update boolean value using UPDATE command. If you use the BOOLEAN data type, MySQL internally convert it into tinyint(1). It can takes true or false literal in which true indicates 1 to tinyint(1) and false indicates 0 to tinyint(1).The syntax is as follows −UPDATE yourTableName SET yourColumnName = ... Read More

What is the best datatype for currencies in MySQL?

Arjun Thakur

Arjun Thakur

Updated on 30-Jun-2020 07:03:33

197 Views

The best data type for currencies in MySQL is a DECIMAL. The syntax of DECIMAL data type is as follows −DECIMAL(TotalDigit, NumberOfDigitAfterDecimalPoint);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table CurrenciesDemo    -> (    -> TotalPrice ... Read More

Get table column names in alphabetical order in MySQL?

Arjun Thakur

Arjun Thakur

Updated on 30-Jun-2020 06:31:17

2K+ Views

To get the table column names in alphabetical order, you need to use ORDER BY. The syntax is as follows −SELECT anyReferenceName.COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS anyReferenceName WHERE anyReferenceName.TABLE_NAME = ’yourTableName’ ORDER BY anyReferenceName.COLUMN_NAMEFirst, we need to get all the columns and then we need to use ORDER BY. In the above ... Read More

How to ORDER BY LIKE in MySQL?

Arjun Thakur

Arjun Thakur

Updated on 30-Jun-2020 06:19:10

2K+ Views

To order by like in MySQL, use the case statement. The syntax is as follows −SELECT *FROM yourTableName    ORDER BY CASE    WHEN yourColumnName like '%yourPatternValue1%' then 1    WHEN yourColumnName like '%yourPatternValue2%' then 2 else 3 end;To understand the above syntax, let us create a table. The query ... Read More

Use Iterator to remove an element from a Collection in Java

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:54:59

19K+ Views

An element can be removed from a Collection using the Iterator method remove(). This method removes the current element in the Collection. If the remove() method is not preceded by the next() method, then the exception IllegalStateException is thrown.A program that demonstrates this is given as follows.Example Live Demoimport java.util.ArrayList; import ... Read More

Obtain the Previous Index and Next Index in an ArrayList using the ListIterator in Java

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:48:53

1K+ Views

The previous index and next index in an ArrayList can be obtained using the methods previousIndex() and nextIndex() respectively in the ListIterator Interface.The previousIndex() method returns the index of the element that is returned by the previous() method while the nextIndex() method returns the index of the element that is ... Read More

Get the unmodifiable view of the specified ArrayList in Java

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:42:25

531 Views

The unmodifiable view of the specified ArrayList can be obtained by using the method java.util.Collections.unmodifiableList(). This method has a single parameter i.e. the ArrayList and it returns the unmodifiable view of that ArrayList.A program that demonstrates this is given as followsExample Live Demoimport java.util.ArrayList; import java.util.ArrayList; import java.util.Collections; import java.util.List; public ... Read More

Check for the existence of a key in Java IdentityHashMap

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:20:52

132 Views

Use the containsKey() method to check whether a particular key exists in IdentityHashMap or not.Create a IdentityHashMapMap m = newIdentityHashMap(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50); m.put("7", 90); m.put("8", 250); m.put("9", 350); m.put("10", 450);Now, let’s say we need to check whether key 7 exists ... Read More

Fetch the value for a specific key in Java IdentityHashMap

Arjun Thakur

Arjun Thakur

Updated on 29-Jun-2020 13:10:08

2K+ Views

To fetch the value for a specific key, use the get() method.As a parameter, set the key you want to fetch and fetch the value.Let’s say you need to fetch value of key 3get("3")The following is an example to fetch the value for a specific key in Java IdentityHashMap −Example Live ... Read More

Previous 1 ... 5 6 7 8 9 ... 103 Next
Advertisements