Multiply Two Cells for Each Row in MySQL

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

212 Views

You can use multiplication operator (*) between two cells. The syntax is as followsSELECT yourColumnName1, yourColumnName2, yourColumnName1*yourColumnName2 as ‘anyVariableName’ from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table MultiplicationDemo    -> (    -> FirstPrice int,    -> SecondPrice int    -> ); Query OK, 0 rows affected (0.63 sec)Now you can display all records from the table using insert command. The query is as followsmysql> insert into MultiplicationDemo values(10, 2); Query OK, 1 row affected (0.17 sec) mysql> insert into MultiplicationDemo values(4, 2); Query OK, ... Read More

Add Live Camera Preview to UIView in Swift

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

848 Views

To add a live camera preview to our default UIView in swift we can either use AVFoundation framework of iOS SDK or native UIImagePickerController(). In this example we’ll be using ImagePicker as our aim is to present camera preview on the UIView and Imagepicker is suitable for that task. AVFoundation can be used when we need a lot of customization on our camera or different types of custom actions.To show a camera preview on the UIView we need to perform the following steps.Create a UIImagePickerController object.Conform our class to UIImagePickerControllerDelegate and UINavigationControllerDelegate.Assign delegates to the object we created in step ... Read More

Using the finalize Method in Java Garbage Collection

Vikyath Ram
Updated on 30-Jul-2019 22:30:24

1K+ Views

When a garbage collector determines that no more references are made to a particular object, then the finalize() method is called by the garbage collector on that object. The finalize() method requires no parameters and does not return a value.A program that demonstrates the finalize() method in Java is given as follows:Example Live Demoimport java.util.*; public class Demo extends GregorianCalendar {    public static void main(String[] args) {       try {          Demo obj = new Demo();          System.out.println("The current time is: " + obj.getTime());          obj.finalize();       ... Read More

Select MySQL Rows Where Today's Date is Between Two Date Columns

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

1K+ Views

To select MySQL rows where today’s date is between two date columns, you need to use AND operator. The syntax is as follows:SELECT *FROM yourTableName WHERE yourDateColumnName1 = ‘’yourDateValue’;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table selectDates -> ( -> Id int NOT NULL AUTO_INCREMENT, -> StartingDate date, -> EndingDate date, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.80 sec)Now you can insert some records in ... Read More

Working with BigDecimal Values in Java

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

1K+ Views

The java.math.BigDecimal class provides operations for arithmetic, scale manipulation, rounding, comparison, hashing, and format conversion.Two types of operations are provided for manipulating the scale of a BigDecimal −scaling/rounding operationsdecimal point motion operationsThe following are some of the constructors of the BigDecimal values −Sr.No.Constructor & Description1BigDecimal(BigInteger val)This constructor is used to translates a BigInteger into a BigDecimal.2BigDecimal(BigInteger unscaledVal, int scale)This constructor is used to translate a BigInteger unscaled value and an int scale into a BigDecimal.3BigDecimal(BigInteger unscaledVal, int scale, MathContext mc)This constructor is used to translate a BigInteger unscaled value and an int scale into a BigDecimal, with rounding according to ... Read More

Get Minimum of Three Long Values in Java

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

104 Views

Firstly, let us declare and initialize three long values.long val1 = 88799; long val2 = 98567; long val3 = 98768;Now, find the minimum of three long values using the following condition −// checking for maximum if (val2 < val1) { val1 = val2; } if (val3 < val1) { val1 = val3; }The following is the complete example to get the minimum value −Example Live Demopublic class Demo { public static void main(String[] args) { long val1 = 88799; long ... Read More

Increase VARCHAR Size of Existing Column in MySQL

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

610 Views

Increase the varchar size of an existing column in a database with the help of CHANGE command. The syntax is as follows −alter table yourTableName change yourColumnName yourColumnName dataType;Here, we are creating a table with a single column and varchar size 200 −mysql> create table IncreaseVarcharDemo    −> (    −> StudentId varchar(200)    −> ); Query OK, 0 rows affected (0.60 sec)Now insert record in the table. The query is as follows −mysql> insert into IncreaseVarcharDemo values('John123'); Query OK, 1 row affected (0.16 sec)Displaying all records from the table with the help of the following query −mysql> select *from ... Read More

Limit Length of Longtext Field in MySQL Select Results

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

1K+ Views

You can use SUBSTRING() from MySQL to limit length of strings. The syntax is as followsSELECT SUBSTRING(yourColumnName, 1, yourIntegerValueToGetTheCharacters) as anyVariableName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table limitLengthOfLongTextDemo -> ( -> sentence LONGTEXT -> ); Query OK, 0 rows affected (0.74 sec)Insert some records in the table using insert command. The query is as followsmysql> insert into limitLengthOfLongTextDemo values('This is the introduction to MySQL'); Query OK, 1 row affected (0.17 sec) mysql> insert into ... Read More

Obtain Hash Code for a String in Java

Fendadis John
Updated on 30-Jul-2019 22:30:24

313 Views

The hashCode() method is used to obtain the hash code for a string. This method does not accept any parameters as it is a default method and it returns a hash code value.A program that demonstrates the hashCode() method in Java is given as follows:Example Live Demoimport java.io.*; public class Demo {    public static void main(String args[]) {       String str = new String("The sky is blue");       System.out.println("The string is: " + str);       System.out.println("The Hashcode for the string is: " + str.hashCode());    } }OutputThe string is: The sky is blue The ... Read More

Which is a Better Branch of Engineering: Mech or ECE?

Samrat T
Updated on 30-Jul-2019 22:30:24

143 Views

Both Mechanical Engineering and Electronics and Communication Engineering are equally potential branches. Both are awesome in their own way.Mech guy applies Engineering in designing and manufacturing while electric guys use their knowledge to build Electric circuits and other systems. Check for yourself, where do you belong to and do some serious research before you finalize which branch you want to opt for in your graduation.

Advertisements