Move Data Between Two Tables with Different Columns in MySQL Databases

George John
Updated on 30-Jul-2019 22:30:25

579 Views

For this, you need to use an INSERT SELECT statement. The syntax is as followsINSERT INTO yourDatabaseName1.yourTableName1(yourColumnName1, yourColumnName2, ....N) SELECT yourColumnName1, yourColumnName2, ....N FROM yourdatabaseName2.yourTableName2;Here, I am using the following two databasessampletestLet us create the first table in the “test” databasemysql> use test; Database changed mysql> create table send    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(20) -> ); Query OK, 0 rows affected (1.19 sec)Insert some records in the first table using insert command. The query is as followsmysql> insert into send(Name) values('John'); Query OK, 1 row affected ... Read More

Apply for Tokens Tag in JSP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

230 Views

The tag has similar attributes as that of the tag except for one additional attribute delims which specifies characters to use as delimiters.AttributeDescriptionRequiredDefaultdelimsCharacters to use as delimitersYesNoneExample for           Tag Example                               The above code will generate the following result −Zara nuha roshy

LocalDate minus Method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

3K+ Views

An immutable copy of a LocalDate where the required duration is subtracted from it can be obtained using the minus() method in the LocalDate class in Java. This method requires two parameters i.e. the duration to be subtracted and the TemporalUnit of the duration. Also, it returns the LocalDate object with the required duration subtracted from it.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-15"); System.out.println("The ... Read More

IntStream toArray Method in Java

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

267 Views

The toArray() method returns an array containing the elements of this stream.Set the elements in the stream with the IntStream class of() method.IntStream stream = IntStream.of(20, 40, 60, 70, 100, 120, 140);Now, display an array with the elements of this stream using the toArray() method.int[] myArr = stream.toArray();The following is the syntax.int[] toArray()The following is an example to implement IntStream toArray() method in Java.Example Live Demoimport java.util.*; import java.util.stream.IntStream; public class Demo {    public static void main(String[] args) {       IntStream stream = IntStream.of(20, 40, 60, 70, 100, 120, 140);       int[] myArr = stream.toArray();       System.out.println(Arrays.toString(myArr));    } }Output[20, 40, 60, 70, 100, 120, 140]

Create New Table by Merging Two Tables with MySQL UNION

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

3K+ Views

The following is the syntax to merge two tables using MySQL unioncreate table yourTableName ( select *from yourTableName1 ) UNION ( select *from yourTableName2 );To understand the above syntax, let us create a table. The query to create first table is as followsmysql> create table Old_TableDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20) -> ); Query OK, 0 rows affected (0.63 sec)The query to create second table is as followsmysql> create table Old_TableDemo2 ... Read More

Find Deepest Left Leaf in a Binary Tree using C++

Samual Sam
Updated on 30-Jul-2019 22:30:25

202 Views

A binary tree which has at most two children, specified as left child and right child. This is a C++ Program to Find Deepest Left Leaf in a Binary TreeAlgorithmBegin.    function deepestLLeafutil() find the deepest left leaf in a given    binary tree:         lvel is level of current node.       maxlvel is pointer to the deepest left leaf node found so far         isLeft Indicates that this node is left child of its parent         resPtr is Pointer to the result         If root is equal to Null ... Read More

Add Radio Button List in Alert Dialog

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

3K+ Views

This example demonstrate about how to add radio button list in alert dialogStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken text view.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.TargetApi; import android.content.DialogInterface; import android.os.Build; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Switch; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    TextView text;    @TargetApi(Build.VERSION_CODES.LOLLIPOP)   ... Read More

Generate Non-Repeating Random Values in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

444 Views

To generate random values that won’t repeat, use HashSet collection. Firstly, create a random object and HashSet −Random randNum = new Random(); Sets = new HashSet();Now, add random integers −while (s.size() < 10) {    s.add(randNum.nextInt()); }Now, display the random numbers that are unique −Listlist = new ArrayList(s); System.out.println(list);Example Live Demoimport java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.util.Random; import java.util.List; public class Demo {    public static void main(String[] args) {       Random randNum = new Random();       Sets = new HashSet();       while (s.size() < 10) {          s.add(randNum.nextInt());     ... Read More

Difference Between Pretty Function, Function, and Func in C/C++

Smita Kapse
Updated on 30-Jul-2019 22:30:25

2K+ Views

Here we will see what are the differences between __FUNCTION__, __func__ and the __PRETTY_FUNCTION__ in C++.Basically the __FUNCTION__ and __func__ are same. Some old versions of C and C++ supports __func__. This macro is used to get the name of the current function. The _PRETTY_FUNCTION__ is used to return the detail about the function. Using this we can get which function is used, and in which class it is belonging, etc.Example#include using namespace std; class MyClass{    public:       void Class_Function(){          cout

W and Z Registers in 8085 Microprocessor

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

3K+ Views

To define Temporary Register, we can mention that it is an 8-bit non-programmable resister used to hold data during an arithmetic and logic operation (temporary resister is used to hold intermediate result). The result is stored in the accumulator, and the flags (flip-flops) are set or reset according to the result of the operation.W and Z are two 8-bit temporary registers of 8085 microprocessor, which is not accessible to the user. They are exclusively used for the internal operation by the microprocessor. These registers are used either to store 8-bit of information in each W and Z registers or a ... Read More

Advertisements