How to combine two tables and add a new column with records in MySQL?

Rama Giri
Updated on 30-Jul-2019 22:30:26

434 Views

Let us first create a table −mysql> create table DemoTable1    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100)    -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(Name) values('Chris'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1(Name) values('Robert'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;Output+----+--------+ | Id | Name   | +----+--------+ |  1 | Chris  | |  2 | Robert | +----+--------+ 2 ... Read More

Add N digits to A such that it is divisible by B after each addition in C++?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

108 Views

Here we will see how to generate a number A by adding N digits with it, and while adding new digits in each stage it will be divisible by another number B. Let us consider we are going to make a 5-digit number by adding 4 extra digits with it. We will check the divisibility by 7. The number will start from 8. So at first it will append 4 with it, so the number will be 84, that is divisible by 7. Then add 0 with the number so it will remain divisible by 7. If the number cannot ... Read More

HTML DOM lastElementChild Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

28 Views

The HTML DOM lastElementChild property returns the last element node as node object of the specified node.NOTE − This property does ignore text and comment nodesSyntaxFollowing is the syntax −Returning lastElementChild nodenodeList.lastElementChildExampleLet us see an example for HTML DOM lastElementChild property − Live Demo HTML DOM lastElementChild    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    }    ul{       width: 30%; ... Read More

What is a free function in C++?

Anvi Jain
Updated on 30-Jul-2019 22:30:26

261 Views

The C/C++ library function void free(void *ptr) deallocates the memory previously allocated by a call to calloc, malloc, or realloc. Following is the declaration for free() function.void free(void *ptr)This function takes a pointer ptr. This is the pointer to a memory block previously allocated with malloc, calloc or realloc to be deallocated. If a null pointer is passed as argument, no action occurs.Example#include #include #include using namespace std; int main () {    char *str;    /* Initial memory allocation */    str = (char *) malloc(15);    strcpy(str, "tutorialspoint");    cout

How to display the first element in a JComboBox in Java

Nancy Den
Updated on 30-Jul-2019 22:30:26

520 Views

To display the first element in a JComboBox, use the getSelectedIndex():comboBox.setSelectedIndex(0);The following is an example to display the first element in a JComboBox in Java:Exampleimport java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; public class SwingDemo {    public static void main(String[] args) {       JPanel panel = new JPanel(new BorderLayout());       String[] strArr = new String[] { "Laptop", "Mobile", "Desktop", "Tablet" };       JComboBox comboBox = new JComboBox(strArr);       panel.add(comboBox, BorderLayout.NORTH);       JTextArea text = new JTextArea(5, 5);       panel.add(text, ... Read More

How to close the notification panel after notification button is clicked in Android?

Anvi Jain
Updated on 30-Jul-2019 22:30:26

1K+ Views

This example demonstrate about How to close the notification panel after notification button is clicked in AndroidStep 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.     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Context ; import android.content.Intent ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; public class MainActivity extends AppCompatActivity { ... Read More

IPC using Message Queues

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

3K+ Views

Why do we need message queues when we already have the shared memory? It would be for multiple reasons, let us try to break this into multiple points for simplification −As understood, once the message is received by a process it would be no longer available for any other process. Whereas in shared memory, the data is available for multiple processes to access.If we want to communicate with small message formats.Shared memory data need to be protected with synchronization when multiple processes communicating at the same time.Frequency of writing and reading using the shared memory is high, then it would ... Read More

How to set the alignment of the JLabel content along the Y axis on the top in Java

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

108 Views

To set the alignment of the label’s content along the Y axis on the top, use the setVerticalAlignment() method and set the location. Let us first set a label component. We have set the label background color as well so that we can check the alignment of the label’s content properly −JLabel label = new JLabel("Favourite Movie"); label.setPreferredSize(new Dimension(190, 100)); label.setOpaque(true); label.setBackground(Color.GREEN); label.setForeground(Color.WHITE);Now, we will align the label content along the Y axis on the top by seeting location as TOP −label.setVerticalAlignment(JLabel.TOP);The following is an example to set the alignment of the JLabel content along the Y axis on the ... Read More

Getting a list of values by using MongoDB $group?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

1K+ Views

To get a list of values, use $group aggregation along with $push operator. Let us first create a collection with documents −> db.groupByDemo.insertOne({"UserName":"John", "Subject":"MongoDB"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd69f0457806ebf1256f136") } > db.groupByDemo.insertOne({"UserName":"Larry", "Subject":"MySQL"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd69f0657806ebf1256f137") } > db.groupByDemo.insertOne({"UserName":"John", "Subject":"Java"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd69f0d57806ebf1256f138") } > db.groupByDemo.insertOne({"UserName":"John", "Subject":"C"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd69f1357806ebf1256f139") } > db.groupByDemo.insertOne({"UserName":"Larry", "Subject":"SQL Server"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd69f1c57806ebf1256f13a") }Following is the query to display all documents from a collection with the help ... Read More

HTML placeholder Attribute

Chandu yadav
Updated on 30-Jul-2019 22:30:26

303 Views

The placeholder attribute of the element is used to set a hint for the input that would give a short description about what is expected in that particular input. This attribute works for the following input types − text, url, search, email, password and tel. It introduced in HTML5.Following is the syntax −Here, placeholder_text is the short hint i.e. placeholder which would be visible to the users whenever they will visit that web page.Let us now see an example to implement the placeholder attribute of the element −Example Live Demo Register Id − ... Read More

Advertisements