Combine Built-in Commands g and G for MySQL Execution

mkotla
Updated on 22-Jun-2020 11:33:43

109 Views

As we know that built-in-commands (\G and \g) send the command to MySQL server for execution and both of them have the different format of the result set. For combining them and getting the result without error, we need to write two queries, one query with \G and other with \g at the end, in a single statement.Examplemysql> Select * from student\G select * from ratelist\g *************************** 1. row ***************************   Name: Gaurav RollNo: 100  Grade: B.tech *************************** 2. row ***************************   Name: Aarav RollNo: 150  Grade: M.SC *************************** 3. row ***************************   Name: Aryan RollNo: 165  Grade: M.tech 3 ... Read More

Result of Arithmetic Calculations in MySQL with NULL Arguments

radhakrishna
Updated on 22-Jun-2020 11:33:08

129 Views

MySQL always throws NULL as the result of arithmetic calculations in which one of the arguments is NULL. Consider the following example having NULL as an argument with addition, subtraction, multiplication, and division −mysql> Select 10*NULL; +---------+ | 10*NULL | +---------+ |    NULL | +---------+ 1 row in set (0.12 sec) mysql> Select 10+NULL; +---------+ | 10+NULL | +---------+ | NULL | +---------+ 1 row in set (0.00 sec) mysql> Select 10-NULL; +---------+ | 10-NULL | +---------+ |    NULL | +---------+ 1 row in set (0.07 sec) mysql> Select 10/NULL; +---------+ | 10/NULL | +---------+ ... Read More

Java Strictly Pass-by-Value Explained

Arushi
Updated on 22-Jun-2020 11:32:45

351 Views

Call by Value means calling a method with a parameter as value. Through this, the argument value is passed to the parameter.While Call by Reference means calling a method with a parameter as a reference. Through this, the argument reference is passed to the parameter.In call by value, the modification done to the parameter passed does not reflect in the caller's scope while in the call by reference, the modification done to the parameter passed are persistent and changes are reflected in the caller's scope. But Java uses only call by value. It creates a copy of references and pass ... Read More

Use Built-in Commands G and g with Semicolon in MySQL Statement

Krantik Chavan
Updated on 22-Jun-2020 11:32:31

173 Views

As we know that built-in-commands (\G and \g) send the command to MySQL server for execution and with the help of Semicolon (;) MySQL determines the end of the statement. For using all three and getting the result without error, we need to write three queries, one query with \G, one with \g and other with a semicolon (;) in the end, in a single statement.Examplemysql> Select * from student\G select * from ratelist\g select NOW(); *************************** 1. row ***************************   Name: Gaurav RollNo: 100  Grade: B.tech *************************** 2. row ***************************   Name: Aarav RollNo: 150  Grade: M.SC *************************** 3. ... Read More

MySQL Transaction Behavior When Session Ends

Moumita
Updated on 22-Jun-2020 11:31:42

183 Views

Suppose if a session is ended in the middle of a transaction then that current MySQL transaction will be rolled back by MySQL and ended. It means that all the database changes made in the current transaction will be removed. It is called n implicit rollback when the session is ended.ExampleSuppose we have the following values in the table ‘marks’mysql> Select * from marks; +------+---------+-----------+-------+ | Id   | Name    | Subject   | Marks | +------+---------+-----------+-------+ | 1    | Aarav   | Maths     | 50    | | 1    | Harshit | Maths   ... Read More

Compare Two Arrays in Java

Paul Richard
Updated on 22-Jun-2020 11:31:37

14K+ Views

Arrays can be compared using following ways in JavaUsing Arrays.equals(array1, array2) methods − This method iterates over each value of an array and compare using equals method.Using Arrays.deepEquals(array1, array2) methods − This method iterates over each value of an array and deep compare using any overridden equals method.Using == on array will not give the desired result and it will compare them as objects. See the example below for each of the comparison way.Example Live Demoimport java.util.Arrays; public class Tester{    public static void main(String[] args) {       int[] array1 = {1, 2, 3};       int[] ... Read More

Why MySQL Cannot Use Arithmetic Operators with NULL

vanithasree
Updated on 22-Jun-2020 11:31:08

217 Views

The reason behind it is that we will not receive any meaningful results from the comparisons when we use NULL with the comparison operators like ‘=’, ‘ Select 10 = NULL, 10< NULL, 10NULL; +-----------+----------+----------+ | 10 = NULL | 10< NULL | 10NULL | +-----------+----------+----------+ |      NULL |     NULL |     NULL | +-----------+----------+----------+ 1 row in set (0.07 sec)The above result set is not meaningful in any sense.

Measure Time Taken by a Function in Java

Arushi
Updated on 22-Jun-2020 11:30:52

370 Views

java.lang.System.currentTimeMillis() method can be used to compute the time taken by a function in java. Trick is simple. Get the before time and after time using currentTimeMillis() where before time is the time when method is invoked and after time is when method has executed. See the example below −Example Live Demopublic class Tester{    public static void main(String[] args) {       long startTime = System.currentTimeMillis();       longRunningMethod();       long endTime = System.currentTimeMillis();       System.out.println("Time taken: " + (endTime -startTime) + " ms");    }    private static void longRunningMethod() {       try {          Thread.sleep(1000);       } catch (InterruptedException e) {          e.printStackTrace();       }    } }OutputTime taken: 1000 ms

MySQL Transaction and DDL Statement Execution

Chandu yadav
Updated on 22-Jun-2020 11:30:35

335 Views

The current MySQL transaction will be committed and ended when any of the DDL statement such as CREATE or DROP databases, Create, ALTER or DROP tables or stored routines is executed in the middle of the current transaction. All the database changes made in the current transaction will be made permanent and cannot be rolled back.Examplemysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO MARKS Values(6, 'Manak', 'History', 70); Query OK, 1 row affected (0.26 sec) mysql> Create table student(id int, Name Varchar(10), ); Query OK, 0 rows affected (0.84 sec)As we can see ... Read More

Parse JSON in Java

Arushi
Updated on 22-Jun-2020 11:30:03

4K+ Views

This articles covers how to encode and decode JSON objects using Java programming language. Let's start with preparing the environment to start our programming with Java for JSON.EnvironmentBefore you start with encoding and decoding JSON using Java, you need to install any of the JSON modules available. For this tutorial we have downloaded and installed JSON.simple and have added the location of json-simple-1.1.1.jar file to the environment variable CLASSPATH.Mapping between JSON and Java entitiesJSON.simple maps entities from the left side to the right side while decoding or parsing, and maps entities from the right to the left while encoding.JSONJavastringjava.lang.Stringnumberjava.lang.Numbertrue|falsejava.lang.Booleannullnullarrayjava.util.Listobjectjava.util.MapOn decoding, ... Read More

Advertisements