Ankith Reddy has Published 1070 Articles

Is BIGINT(8) the largest integer MySQL can store?

Ankith Reddy

Ankith Reddy

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

3K+ Views

In BIGINT(8), the number 8 represents how the data will be displayed. It does not affect the storage. The number is used to display width.BIGINT takes 8 bytes i.e. 64 bits. The signed range is -9223372036854775808 to 9223372036854775807 and unsigned range takes positive value. The range of unsigned is 0 ... Read More

How to disable landscape mode in Android?

Ankith Reddy

Ankith Reddy

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

2K+ Views

Android supports two orientations as portrait and landscape. we can disable orientation in android application. This example demonstrate about how to disable landscape mode in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new ... Read More

Get a random value between two values in MySQL?

Ankith Reddy

Ankith Reddy

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

6K+ Views

To get the random value between two values, use MySQL rand() method with floor(). The syntax is as follows.select FLOOR( RAND() * (maximumValue-minimumValue) + minimumValue) as anyVariableName;Let us check with some maximum and minimum value. The maximum value we are considering is 200 and minimum is 100. The random number ... Read More

How to Stop EditText from gaining focus at Activity startup in Android

Ankith Reddy

Ankith Reddy

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

2K+ Views

There are so many situations where we don't required keyboard visibility when activity starts. This example demonstrate about how to Stop EditText from gaining focus at Activity startupStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create ... Read More

Fill elements in a Java char array in a specified range

Ankith Reddy

Ankith Reddy

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

186 Views

Elements can be filled in a Java char array in a specified range using the java.util.Arrays.fill() method. This method assigns the required char value in the specified range to the char array in Java.The parameters required for the Arrays.fill() method are the array name, the index of the first element ... Read More

How can I loop through all rows of a table in MySQL?

Ankith Reddy

Ankith Reddy

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

7K+ Views

To loop through all rows of a table, use stored procedure in MySQL. The syntax is as follows −delimiter // CREATE PROCEDURE yourProcedureName() BEGIN DECLARE anyVariableName1 INT DEFAULT 0; DECLARE anyVariableName2 INT DEFAULT 0; SELECT COUNT(*) FROM yourTableName1 INTO anyVariableName1; SET anyVariableName2 =0; WHILE anyVariableName2 < anyVariableName1 DO    INSERT ... Read More

Retrieve the first entry in the TreeMap in Java

Ankith Reddy

Ankith Reddy

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

2K+ Views

Use the firstEntry() method in TreeMap to retrieve the first entry.Create a TreeMap and add some elementsTreeMap m = new TreeMap(); m.put(1, "India"); m.put(2, "US"); m.put(3, "Australia"); m.put(4, "Netherlands"); m.put(5, "Canada");Now, retrieve the first entrym.firstEntry()The following is an example to retrieve first entry in the TreeMapExample Live Demoimport java.util.*; public class ... Read More

How to use FOR LOOP in MySQL Stored Procedure?

Ankith Reddy

Ankith Reddy

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

2K+ Views

The following is the syntax to work with FOR LOOP in MySQL stored procedure −delimiter // CREATE procedure yourProcedureName() wholeblock:BEGIN DECLARE anyVariableName1 INT ; Declare anyVariableName3 int; DECLARE anyVariableName2 VARCHAR(255); SET anyVariableName1 =1 ; SET ... Read More

Select multiple sums with MySQL query and display them in separate columns?

Ankith Reddy

Ankith Reddy

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

827 Views

To select multiple sum columns with MySQL query and display them in separate columns, you need to use CASE statement. The syntax is as follows:SELECT SUM( CASE WHEN yourColumnName1=’yourValue1’ THEN yourColumnName2 END ) AS yourSeparateColumnName1, SUM( CASE WHEN yourColumnName1=’yourValue2’ THEN yourColumnName2 END ) AS yourSeparateColumnName2, SUM( CASE WHEN yourColumnName1=’yourValue3’ THEN ... Read More

How to create JSON format with group-concat in MySQL?

Ankith Reddy

Ankith Reddy

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

1K+ Views

You can create JSON format using group_concat() function from MySQL. The syntax is as follows −SELECT yourColumnName1, GROUP_CONCAT(CONCAT('{anytName:"', yourColumnName, '", anyName:"', yourColunName, '"}')) anyVariableName from yourTableName group by yourColumnName1;To understand the above syntax, let us first create a table. The query to create a ... Read More

Advertisements