Multiply values of two columns and display it a new column in MySQL?

Kumar Varma
Updated on 30-Jul-2019 22:30:26

3K+ Views

Let us first create a table −mysql> create table DemoTable    -> (    -> NumberOfItems int,    -> Amount int    -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(4, 902); Query OK, 1 row affected (0.45 sec) mysql> insert into DemoTable values(5, 1000); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(3, 80); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+---------------+--------+ | NumberOfItems | Amount | +---------------+--------+ |   ... Read More

C++ Program for Common Divisors of Two Numbers?

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

210 Views

Here we will see how we can get the number of common divisors of two numbers. We are not going to find all common divisors, but we will count how many common divisors are there. If two numbers are like 12 and 24, then common divisors are 1, 2, 3, 4, 6, 12. So there are 6 common divisors, so the answer will be 6.AlgorithmcountCommonDivisor(a, b)begin    count := 0    gcd := gcd of a and b    for i := 1 to square root of gcd, do       if gcd is divisible by 0, then   ... Read More

HTML DOM lastModified Property

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

38 Views

The HTML DOM lastModified property returns the date and time the current document was last modified.SyntaxFollowing is the syntax −Returning date and time −document.lastModifiedExampleLet us see an example for HTML DOM lastModified property − Live Demo HTML DOM lastModified    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } HTML-DOM-lastModified NOTICE:    var divDisplay = document.getElementById("divDisplay");    var textSelect = document.getElementById("textSelect");    function getNoticeIssuedTime() {       divDisplay.textContent = 'Notice was issued on: '+document.lastModified;    } OutputThis will produce the following output −Before clicking ‘When was this issued?’ button −After clicking ‘When was this issued?’ button −

Java Program to convert Stream to typed array

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

194 Views

Let us first create a Stream:Stream stream = Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming");Now convert the above stream to typed array:final String[] strArr = stream.toArray(String[]::new);The following is an example to convert Stream to typed array in Java:Exampleimport java.util.Arrays; import java.util.stream.Stream; public class Demo {    public static void main(String[] args) {       Stream stream = Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming");       final String[] strArr = stream.toArray(String[]::new);       System.out.println("Array...");       Arrays.asList(strArr).forEach(n-> System.out.println(n));    } }OutputArray... Bing Bang Theory Vampire Diaries Game of Thrones HomecomingRead More

How to display the items in a JComboBox in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

573 Views

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, BorderLayout.CENTER);       JButton btn = new JButton("Click");   ... Read More

Java DatabaseMetaData supportsUnion() method with example.

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

39 Views

The SQL UNION clause/operator is used to combine the results of two or more SELECT statements without returning any duplicate rows.To use this UNION clause, each SELECT statement must haveThe same number of columns selectedThe same number of column expressionsThe same data type andHave them in the same orderBut they need not have to be in the same length.The basic syntax of a UNION clause is as follows −SyntaxSELECT column1 [, column2 ] FROM table1 [, table2 ] [WHERE condition] UNION SELECT column1 [, column2 ] FROM table1 [, table2 ] [WHERE condition]The supportsUnion() method of the DatabaseMetaData interface is used to ... Read More

Write a number array and add only odd numbers?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

941 Views

Odd number summation using JavaScript. Live DemoExample var tot = 0; var a = [1,45,78,9,78,40,67,76]; for(var i = 0; i

How to use range-based for() loop with std::map?

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

1K+ Views

Here we will see how to use the range based for loop for std::map type objects. In C++, we know that there are map type objects. That can store key value pairs. The map basically stores the pair objects. This pair object is used to store one key and corresponding value. These keys and values are implemented using templates, so we can use any type of data.To use the range based for loop, we can define for loop that can iterate through each pair of the map. Let us see the code to get the better idea.Example Code#include #include using ... Read More

How to add JRadioButtonMenuItem in Java

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

115 Views

Let’s say we have a menu and within that we need to set the JRadioButtonMenuItem. Here’s the Menu −JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); menuBar.add(editMenu);Now, set the editMenu and add it to the MenuBar −JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); menuBar.add(editMenu);Now, create Options Menu and add it to the editMenu −JMenu optionsMenu = new JMenu("Options"); optionsMenu.setMnemonic(KeyEvent.VK_O); editMenu.add(optionsMenu);Now, set the JRadioButtonMenuItem and add it to the editMenu created above −ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem radioMenuItem = new JRadioButtonMenuItem("SmartInsertMode", true); radioMenuItem.setMnemonic(KeyEvent.VK_I); optionsMenu.add(radioMenuItem); group.add(radioMenuItem); JRadioButtonMenuItem radioMenuItem2 = new JRadioButtonMenuItem("SmartDeleteMode"); radioMenuItem.setMnemonic(KeyEvent.VK_D); optionsMenu.add(radioMenuItem2); group.add(radioMenuItem2);The following is an example add JRadioButtonMenuItem in Java −Examplepackage my; ... Read More

How to sort by value with MySQL ORDER BY?

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

133 Views

For this, use the ORDER BY clause. Let us first create a table −mysql> create table DemoTable    (    StudentId int    ); Query OK, 0 rows affected (0.59 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(70); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(55); Query OK, 1 row affected ... Read More

Advertisements