Karthikeya Boyini has Published 2383 Articles

Display IDs in a particular order with MySQL IN()?

karthikeya Boyini

karthikeya Boyini

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

151 Views

To display IDs in a particular order i.e. the order of your choice use FIELD() method.Let us first create a table −mysql> create table DemoTable    (    UserId int    ); Query OK, 0 rows affected (0.64 sec)Following is the query to insert some records in the table using ... Read More

Duration plusNanos() method in Java

karthikeya Boyini

karthikeya Boyini

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

52 Views

An immutable copy of a duration where some nanoseconds are added to it can be obtained using the plusNanos() method in the Duration class in Java. This method requires a single parameter i.e. the number of nanoseconds to be added and it returns the duration with the added nanoseconds.A program ... Read More

How to trim commas with MySQL?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

The syntax is as follows to trim commas −SELECT TRIM(BOTH ', ' FROM yourColumnName) from yourTableName;Let us see an example −mysql> create table TrimCommasDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> AllTechnicalSkills text    -> ); Query OK, 0 rows affected (0.81 sec)Now ... Read More

Perform search/replace for only the first occurrence of a character with session variable in MySQL

karthikeya Boyini

karthikeya Boyini

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

141 Views

To perform search/ replace for only the first occurrence, use the CONCAT and REPLACE() function.The query is as follows to set user defined session variable −mysql> set @Sentence='Thks ks is a my string'; Query OK, 0 rows affected (0.00 sec)In this k will be replaced with i only once. The ... Read More

JavaTuples setAt1() method for Quintet class

karthikeya Boyini

karthikeya Boyini

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

56 Views

The setAt1() method is used to set the Quintet value in JavaTuples and a copy with a new value at the specified index i.e. index 1 here.Let us first see what we need to work with JavaTuples. To work with Quintet class in JavaTuples, you need to import the following ... Read More

LocalDate plusDays() Method in Java

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

An immutable copy of the LocalDate where the days are added to it can be obtained using the plusDays() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of days to be added and it returns the instant with the added days.A program ... Read More

Java Program to calculate the area of a triangle using Heron's Formula

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

Heron’s formula gives the area of a triangle when the length of all three sides are already known.Let’s say we have the following three sides of a triangle −s1 = 15191235.0; s2 = 15191235.0; s3 = 1.01235479;Now, use the Heron’s formulae to find the area −area = (s1+s2+s3)/2.0d; resArea = ... Read More

Select current time with MySQL now() and convert it to GMT 0?

karthikeya Boyini

karthikeya Boyini

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

384 Views

You can use utc_timestamp() for this. Following is the syntax −SELECT utc_timestamp();Let us check the current time using now().Following is the query −mysql> select now();This will produce the following output −+---------------------+ | now() | +---------------------+ | ... Read More

Create Septet Tuple from another collection in Java

karthikeya Boyini

karthikeya Boyini

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

64 Views

The fromCollection() method is used in JavaTuples to create Septet Tuple from another collection. We will see an example of creating a Septet Tuple using List collection.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following ... Read More

MySQL add “prefix” to every column?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

To create a view only if it does not already exist, you can use the following syntax −CREATE OR REPLACE VIEW yourViewName AS SELECT *FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table createViewDemo    -> ( ... Read More

Advertisements