Sharon Christine has Published 413 Articles

MySQL query to convert timediff() to seconds?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 10:01:16

561 Views

For this, you can use TIME_TO_SEC() function. Let us first create a table −mysql> create table DemoTable    -> (    -> SourceTime time,    -> DestinationTime time    -> ); Query OK, 0 rows affected (1.33 sec)Insert some records in the table using insert command −mysql> insert into DemoTable ... Read More

How to extract the digit part from the string in MySQL?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 09:50:34

3K+ Views

Let us first create a table −mysql> create table DemoTable    -> (    -> StudentId varchar(100)    -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John19383'); Query OK, 1 row affected (0.18 sec) mysql> insert ... Read More

How to select month and year from dates in MySQL?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 09:49:03

446 Views

To select month and year in MySQL, you can use MONTH() and YEAR() method. Let us first create a table −mysql> create table DemoTable    -> (    -> DueDate datetime    -> ); Query OK, 0 rows affected (0.90 sec)Insert some records in the table using insert command −mysql> ... Read More

Set a certain value first with MySQL ORDER BY?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 09:47:00

1K+ Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Number int    -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.13 sec) mysql> insert ... Read More

Fetch middle part of a string surrounded by slash in MySQL

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 09:36:30

507 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Code varchar(100)    -> ); Query OK, 0 rows affected (1.07 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('/101/102/106'); Query OK, 1 row affected (0.14 sec) mysql> insert ... Read More

How to exclude a specific row from a table in MySQL?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 09:28:04

665 Views

Use i.e. not equal in MySQL to exclude a specific row from a table. Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> FirstName varchar(100)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the ... Read More

Selecting and dividing numbers in a column and displaying the decimal result in integer with MySQL

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 09:26:02

668 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.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Number) values(10); Query ... Read More

Java Program to perform AND operation on BigInteger

Sharon Christine

Sharon Christine

Updated on 29-Jun-2020 05:40:35

140 Views

The java.math.BigInteger.and(BigInteger val) returns a BigInteger whose value is (this & val). This method returns a negative BigInteger if and only if this and val are both negative. Here, “val” is the value to be AND'ed with this BigInteger.First, create BigInteger objects −BigInteger one, two, three; one = new BigInteger("12"); ... Read More

Left pad a string in Java

Sharon Christine

Sharon Christine

Updated on 27-Jun-2020 06:22:59

858 Views

To left pad a string, use the String.format and set the spaces.String.format("|%20s|", "demotext")If you add 30 above, it will display the first string after 30 spaces from the beginning.String.format("|%30s|", "demotext")Example Live Demopublic class Demo {    public static void main(String []args) {       System.out.print(String.format("|%20s|", "demotext"));       System.out.println("Left ... Read More

DataView.getFloat32() function in JavaScript

Sharon Christine

Sharon Christine

Updated on 25-Jun-2020 10:17:22

135 Views

The getFloat32() function of the DataView gets and returns a signed 32-bit floating point number at the specified position.SyntaxIts syntax is as followsdataView.getFloat32();ExampleTry the following example. Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(8);       var dataView = new ... Read More

Advertisements