Implement GREATEST in MySQL and Update the Table

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

202 Views

Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Number int ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Number) values(10); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Number) values(50); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(Number) values(100); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(Number) values(190); Query OK, 1 row affected (0.12 sec)Display all ... Read More

Replace First 10 Characters in JTextArea in Java

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

300 Views

To replace the first 10 character in text area, use the replaceRange() method in Java and replace the old text with the new text.Let’s say the following is oude demo text set with JTextArea −JTextArea textArea = new JTextArea("This is a text displayed for our example. We have replaced some of the text.");Now, replace the characters in a range −int begn = 0; int end = 10; // replace textArea.replaceRange("Replaced! ", begn, end);The following is an example to replace the first 10 charactrers in JTextArea −Examplepackage my; import java.awt.GridLayout; import javax.swing.*; public class SwingDemo {    SwingDemo() {     ... Read More

Make a Phone Call Using Intent in Android

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

995 Views

This example demonstrate about How to lock the Android device programmatically.Step 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/MainActivitypackage app.tutorialspoint.com.sample ; import android.content.Intent ; import android.net.Uri ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ) ... Read More

MongoDB Query to Return Specific Fields from an Array

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

712 Views

To return specific fields, use aggregate $project. Let us first create a collection with documents −> db.returnSpecificFieldDemo.insertOne(    {       "StudentId":1,       "StudentDetails": [          {             "StudentName":"Larry",             "StudentAge":21,             "StudentCountryName":"US"          },          {             "StudentName":"Chris",             "StudentAge":23,             "StudentCountryName":"AUS"          }       ]    } ); {    "acknowledged" ... Read More

Create a Table in JavaDB Using JDBC

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

229 Views

You can create a table in JavaDB database using the CREATE TABLE statement.SyntaxCREATE TABLE table_name (    column_name1 column_data_type1 constraint (optional),    column_name2 column_data_type2 constraint (optional),    column_name3 column_data_type3 constraint (optional) );To create a table in JavaDB using JDBC API you need to −Register the driver − The forName() method of the class, Class accepts a String value representing a class name loads it in to the memory, which automatically registers it. Register the driver using this method.Establish a connection − Connect ot the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) ... Read More

C Program for Difference Between Sums of Odd and Even Digits

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

643 Views

Suppose we have one long integer. We have to find if the differences between the sum of the odd position digits, and the sum of the even position digits are 0 or not. The positions are start from 0 (left most).For example, suppose a number is 156486. The odd position sum is (5 + 4 + 6) = 15, and even position sum is (1 + 6 + 8) = 15, so they are same.To solve this problem, we can use two different ways. The first way is traversing form start to end and get the sum by alternating the ... Read More

Nested Functions in C

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

5K+ Views

In some applications, we have seen that some functions are declared inside another function. This is sometimes known as nested function, but actually this is not the nested function. This is called the lexical scoping. Lexical scoping is not valid in C because the compiler is unable to reach correct memory location of inner function.Nested function definitions cannot access local variables of surrounding blocks. They can access only global variables. In C there are two nested scopes the local and the global. So nested function has some limited use. If we want to create nested function like below, it will ... Read More

Perform Multiplication in SELECT Depending on Column Value in MySQL

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

766 Views

You can use CASE statement for this. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value1 int,    Value2 int    ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value1, Value2) values(10, 5); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(Value1, Value2) values(20, 0); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(Value1, Value2) values(40, 10); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable(Value1, Value2) ... Read More

Use 'this' Keyword in Static Context in Java

Maruthi Krishna
Updated on 30-Jul-2019 22:30:26

1K+ Views

A static method or, block belongs to the class and these will be loaded into the memory along with the class. You can invoke static methods without creating an object. (using the class name as reference).Whereas "this" in Java acts as a reference to the current object. But static contexts(methods and blocks) doesn't have any instance they belong to the class.In a simple sense, to use “this” the method should be invoked by an object, which is not always necessary with static methods.Therefore, you cannot use this keyword from a static method.ExampleIn the following Java program, the class ThisExample contains a private ... Read More

Display PDF Document in Android WebView

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

2K+ Views

This example demonstrate about How to lock the Android device programmatically.Step 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/MainActivitypackage app.tutorialspoint.com.sample ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import android.webkit.WebView ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ) ;    } ... Read More

Advertisements