Kumar Varma

Kumar Varma

88 Articles Published

Articles by Kumar Varma

Page 5 of 9

How can we use ORDER BY clause while calculating the Date?

Kumar Varma
Kumar Varma
Updated on 20-Jun-2020 196 Views

It would be more convenient to find a record if we will use ORDER BY clause while calculating the date. To understand it, we have the data from table ‘Collegedetail’ as follows −mysql> Select * from Collegedetail; +------+---------+------------+ | ID | Country | Estb | +------+---------+------------+ | 111 | INDIA | 2010-05-01 | | 130 | INDIA | 1995-10-25 | | 139 | USA | 1994-09-25 | | 1539 | UK | 2001-07-23 | | 1545 ...

Read More

How can we check for NULL in a MySQL query?

Kumar Varma
Kumar Varma
Updated on 20-Jun-2020 311 Views

With the help of IS NULL operator, we can check for NULL in a MySQL query. We cannot use = (comparison operator) because as we know that NULL is not a value. Following example using the data from ‘employee’ table will exhibit it −Examplemysql> Select * from Employee WHERE Salary IS NULL; +----+-------+--------+ | ID | Name  | Salary | +----+-------+--------+ | 7  | Aryan | NULL   | | 8  | Vinay | NULL   | +----+-------+--------+ 2 rows in set (0.00 sec)The query above use IS NULL operator and produces the output where salary column is having NULL.mysql> ...

Read More

What MySQL returns if sub-query, used to assign new values in the SET clause of UPDATE statement, returns no rows?

Kumar Varma
Kumar Varma
Updated on 20-Jun-2020 199 Views

In this case, MySQL will provide a NULL value to the SET clause. Following example will demonstrate it −Examplemysql> Select * from student; +----+---------+-----------+ | Id | Name    | grade     | +----+---------+-----------+ | 1  | Rahul   | Good      | | 2  | Gaurav  | Good      | | 3  | Raman   | Excellent | | 4  | Harshit | Average   | | 5  | Aarav   | Best      | | 6  | Ram     | average   | +----+---------+-----------+ 6 rows in set (0.00 sec) ...

Read More

How can I insert the values in columns without specifying the names of the column in MySQL INSERT INTO statement?

Kumar Varma
Kumar Varma
Updated on 19-Jun-2020 3K+ Views

For inserting the values in the column without specifying the names of the columns in INSERT INTO statement, we must give the number of values that matches the number of columns in the table along with taking care about the data type of that column too.ExampleIn the example below we have inserted the values without specifying the name of the column.mysql> Insert into student values(100, 'Gaurav', 'Ph.D'); Query OK, 1 row affected (0.08 sec) mysql> Select * from student; +--------+--------+--------+ | RollNO | Name   | Class  | +--------+--------+--------+ | 100    | Gaurav | Ph.D   | +--------+--------+--------+ ...

Read More

How to insert NULL keyword as a value in a character type column of MySQL table having NOT NULL constraint?

Kumar Varma
Kumar Varma
Updated on 19-Jun-2020 297 Views

It is quite possible to insert the NULL keyword as a value in a character type column having NOT NULL constraint because NULL is a value in itself. Following example will exhibit it −ExampleSuppose we have a table test2 having character type column ‘Name’ along with NOT NULL constraint on it. It can be checked from the DESCRIBE statement as follows −mysql> Describe test2\G *************************** 1. row ***************************   Field: id    Type: int(11)    Null: NO     Key: Default: NULL   Extra: *************************** 2. row ***************************   Field: NAME    Type: varchar(20)    Null: NO     Key: ...

Read More

Java (JVM) Memory Types

Kumar Varma
Kumar Varma
Updated on 18-Jun-2020 4K+ Views

Java Virtual Machine is a program/software which takes Java bytecode (.class files)and converts the byte code (line by line) into machine understandable code.JVM contains a module known as a class loader. A class loader in JVM loads, links and, initializes a program. It−Loads the class into the memory. Verifies the byte code instructions.Allocates memory for the program.The memory in the JVM is divided into five different parts namely− Method area− The method area stores the class code − code of the variables and methods. Heap − The Java objects are created in this area. Java Stack− While running methods the results are stored in ...

Read More

Java labelled statement

Kumar Varma
Kumar Varma
Updated on 15-Jun-2020 4K+ Views

Yes. Java supports labeled statements. You can put a label before a for statement and use the break/continue controls to jump to that label. Example See the example below. public class Tester {    public static void main(String args[]) {      first:          for (int i = 0; i 

Read More

How to create a subarray from another array in Java

Kumar Varma
Kumar Varma
Updated on 24-Feb-2020 18K+ Views

Use Arrays.copyOfRange() method to get a subarray.Exampleimport java.util.Arrays; public class Tester { public static void main(String[] args) { int[] array = new int[] {1, 2, 3, 4, 5}; int[] subArray = Arrays.copyOfRange(array, 0, 2); System.out.println("Array: "); for(int i = 0; i < array.length; i++) { System.out.print(array[i] + " "); } System.out.println("Sub array: "); for(int i = 0; i < subArray.length; i++) { System.out.print(subArray[i] + " "); } } }OutputArray: 1 2 3 4 5 Sub array: 1 2

Read More

Is there any way to use values from a JSON object in a MySQL Select statement?

Kumar Varma
Kumar Varma
Updated on 30-Jul-2019 262 Views

Yes, you can use json_extract(). Let us first create a table −mysql> create table DemoTable    -> (    -> Data json    -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('{"Name": "John", "CountryName": "US"}'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable values('{"Name": "Chris", "CountryName": "UK"}'); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+----------------------------------------+ | Data                               ...

Read More

STR_TO_DATE as column, but column not found?

Kumar Varma
Kumar Varma
Updated on 30-Jul-2019 126 Views

You can use having clause. Let us first create a table −mysql> create table DemoTable    -> (    -> AdmissionDate varchar(100)    -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('10/12/2017'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('01/11/2018'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('31/01/2019'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('09/06/2019'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('19/04/2019'); Query OK, 1 ...

Read More
Showing 41–50 of 88 articles
« Prev 1 3 4 5 6 7 9 Next »
Advertisements