Get Output of Multiple MySQL Tables from a Single Query

Vrundesha Joshi
Updated on 22-Jun-2020 11:41:03

398 Views

As we know that a query can have multiple MySQL statements followed by a semicolon. Suppose if we want to get the result from multiple tables then consider the following example to get the result set from ‘Student_info’ and ‘Student_detail’ by writing a single query −mysql> Select Name, Address from Student_info; Select Studentid, Address from Student_detail; +---------+------------+ | Name    | Address    | +---------+------------+ | YashPal | Amritsar   | | Gaurav  | Chandigarh | | Raman   | Shimla     | | Ram     | Jhansi     | | Shyam   | Chandigarh | | ... Read More

Input Multiple Values from User in One Line in C#

Samual Sam
Updated on 22-Jun-2020 11:40:25

3K+ Views

Use a while loop to input multiple values from the user in one line.Let’s say you need to get the elements of a matrix. Get it using Console.ReadLine() as shown below −Console.Write("Enter elements - Matrix 1 : "); for (i = 0; i < m; i++) {    for (j = 0; j < n; j++) {       arr1[i, j] = Convert.ToInt16(Console.ReadLine());    } }The following is an example showing how we can input multiple values from user −Example Live Demousing System; namespace Demo {    public class Program {       public static void Main(string[] args) ... Read More

Use of -c Option in MySQL Statements

Ramu Prasad
Updated on 22-Jun-2020 11:40:20

568 Views

‘\c’ option means ‘clear’ and is used to clear the current input. Suppose if we do not want to execute a command that we are entering, then we can use a clear \c option which clears the current input. For example, the use of \c option can be done as follows −mysql> Select *     -> from\cIn the example above, when we use \c in a statement, MySQL clears the current input and returns back to the MySQL prompt for accepting other statements.

Initialize and Compare Strings in Java

Vikyath Ram
Updated on 22-Jun-2020 11:39:31

186 Views

Following example compares two strings by using str compareTo (string), str compareToIgnoreCase(String) and str compareTo(object string) of string class and returns the ascii difference of first odd characters of compared strings.Example Live Demopublic class StringCompareEmp{    public static void main(String args[]) {       String str = "Hello World";       String anotherString = "hello world";       Object objStr = str;       System.out.println( str.compareTo(anotherString) );       System.out.println( str.compareToIgnoreCase(anotherString) );       System.out.println( str.compareTo(objStr.toString()));    } }OutputThe above code sample will produce the following result.-32 0 0String compare by equals()This method compares ... Read More

Iterate Any Map in Java

Paul Richard
Updated on 22-Jun-2020 11:34:18

212 Views

Following example uses iterator Method of Collection class to iterate through the HashMap.Example Live Demoimport java.util.*; public class Main {    public static void main(String[] args) {       HashMap< String, String> hMap = new HashMap< String, String>();       hMap.put("1", "1st");       hMap.put("2", "2nd");       hMap.put("3", "3rd");       Collection cl = hMap.values();       Iterator itr = cl.iterator();       while (itr.hasNext()) {          System.out.println(itr.next());       }    } }OutputThe above code sample will produce the following result.1st 2nd 3rd

Combine Built-in Commands g and G for MySQL Execution

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

123 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

143 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

376 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

186 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

200 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

Advertisements