Sai Nath

Sai Nath

15 Articles Published

Articles by Sai Nath

Page 2 of 2

How can we divide the result set returned by MySQL into groups?

Sai Nath
Sai Nath
Updated on 20-Jun-2020 1K+ Views

It can be done by using GROUP BY clause in the SELECT statement. We can specify a column as grouping criteria with the help of GROUP BY clause. Due to the specified grouping criteria, rows with the same value in a particular column are considered as a single group. In this way, the result set returned by MySQL SELECT statement will be divided into groups.ExampleFollowing is a good example to understand it −We have a table named ‘employees’ as follows −mysql> Select * from employees; +------+-------------+--------+------------+ | id   | designation | Salary | DoJ        | +------+-------------+--------+------------+ ...

Read More

How can we copy data with some condition/s from existing MySQL table?

Sai Nath
Sai Nath
Updated on 29-Jan-2020 319 Views

As we know that we can copy the data and structure from an existing table by CTAS script. If we want to copy data with some condition/s then we need to use WHERE clause with CTAS script. Consider the example below −mysql> Create table EMP_BACKUP2 AS SELECT * from EMPLOYEE WHERE id = 300 AND Name = 'Mohan'; Query OK, 1 row affected (0.14 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> Select * from EMP_BACKUP2; +------+-------+ | Id   | Name  | +------+-------+ | 300  | Mohan | +------+-------+ 1 row in set (0.00 sec)In the example ...

Read More

how to convert Object array to String array in java

Sai Nath
Sai Nath
Updated on 30-Jul-2019 5K+ Views

As list.toArray() returns an Object[], it can be converted to String array by passing the String[] as parameter. See the example below.import java.util.ArrayList; import java.util.List; public class Tester { public static void main(String[] args) { List data = new ArrayList(); data.add("A"); data.add("B"); data.add("C"); //Object[] objects = data.toArray(); String[] strObjects = data.toArray(new String[0]); for(String obj: strObjects) { System.out.println(obj); } } }OutputA B C

Read More

Why we do not import a package while we use any string function?

Sai Nath
Sai Nath
Updated on 30-Jul-2019 1K+ Views

The String class belongs to the java.lang package. This is the default package of the Java language therefore it is not mandatory to import it to use its classes.

Read More

Immutable String in Java

Sai Nath
Sai Nath
Updated on 30-Jul-2019 834 Views

In Java immutable objects are those whose data can’t be changed or modified (once modified). String class is immutable i.e. once we create a String object its data cannot be modified.

Read More
Showing 11–15 of 15 articles
« Prev 1 2 Next »
Advertisements