To change the column in MySQL from int to double you need to use ALTER TABLE command.The syntax is as follows:ALTER TABLE yourTableName modify column yourColumnName DOUBLE NOT NULL;If you want NULL value then remove NOT NULL from the above syntax. The syntax is as follows:ALTER TABLE yourTableName modify column yourColumnName DOUBLE;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table IntToDoubleDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(10), -> CylinderVolume int, -> PRIMARY KEY(Id) -> ); Query OK, ... Read More
Use the subtract method to subtract one BigDecimal to another in Java. TheBigDecimal.subtract(BigDecimal val) returns a BigDecimal whose value is (this - subtrahend), and whose scale is max(this.scale(), subtrahend.scale()). Here, “val” is the value to be subtracted from this BigDecimal.The following is an example −Example Live Demoimport java.math.BigDecimal; public class Demo { public static void main(String[] argv) throws Exception { BigDecimal val1 = new BigDecimal("375789755.345778656"); BigDecimal val2 = new BigDecimal("625678755.155778656"); System.out.println("Value 1 : "+val1); ... Read More
To work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“ss”) to display seconds in two-digit.Format f = new SimpleDateFormat(”ss”);Now, get the seconds in a string −String strSeconds = f.format(new Date());The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s"); ... Read More
To implement GROUP BY on two fields and count, let us create a table. The following is the query to create a table −mysql> create table GroupByTwoFieldsDemo −> ( −> Id int, −> Name varchar(200) −> ); Query OK, 0 rows affected (0.53 sec)Let us insert some records in the table −mysql> insert into GroupByTwoFieldsDemo values(1, 'John'); Query OK, 1 row affected (0.15 sec) mysql> insert into GroupByTwoFieldsDemo values(10, 'Johnson'); Query OK, 1 row affected (0.16 sec) mysql> insert into GroupByTwoFieldsDemo values(9, 'Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... Read More
Here is a stored procedure that takes one parameter for input (IN) and second parameter for output (OUT)mysql> delimiter // mysql> create procedure Sp_SQRT(IN Number1 INT, OUT Number2 FLOAT) -> Begin -> set Number2=sqrt(Number1); -> end; -> // Query OK, 0 rows affected (0.24 sec) mysql> delimiter ;Call the stored procedure and send the value to the user variable. The syntax is as followsCALL yourStoredProcedureName(anyIntegerValue, @anyVariableName);Check what value is stored in the variable @anyVariableName. The syntax is as followsSELECT @anyVariableName;Created the stored procedure with the name ‘Sp_SQRT’. The ... Read More
You cannot update with regexp i.e. you need to use LIKE operator instead of regexp. MySQL does not provide support for update with regexp. The LIKE operator is as follows:UPDATE yourTableName SET yourColumnName= REPLACE(yourColumnName, yourValue)', '' ) WHERE yourColumnNameLIKE '%yourValueThatWillReplace)%';To understand the above syntax, let us create a table.mysql> create table Replace_Demo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Value varchar(20), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into Replace_Demo(Value) values('221)'); Query OK, 1 ... Read More
You can display AM/PM time marker easily in Java using SimpleDateFormat(“a”).Firstly, to work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“a”) to display AM/PM marker −Format f = new SimpleDateFormat(”a”);Now, get the marker in a string −String strMarker = f.format(new Date());The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time Calendar cal = Calendar.getInstance(); ... Read More
To get dates older than 1 week, you can use the following syntax −select *from yourTableName where yourColumnName < now() - interval 1 week;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table DatesOfOneWeek −> ( −> ArrivalTime datetime −> ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table −mysql> insert into DatesOfOneWeek values(date_add(now(), interval 2 week)); Query OK, 1 row affected (0.11 sec) mysql> insert into DatesOfOneWeek values('2018-11-04'); Query OK, 1 row affected ... Read More
To validate email and phone in swift language we can use multiple conditional statements like if conditions, but that’s a long process and may contain 50-100s of if statements to validate email.So instead of conditionals we’ll use Regular expression. Swift provides NSPredicates which we can use to evaluate a regular expression and test them.Let’s see how we can use regular expressions to do the same.We’ll create a function which we can use as extension of String class or UIViewController to use through out the project.Add the following code to any class in your Project, or create a separate swift class ... Read More
The ftp_ssl_connect() function opens a secure SSL-FTP connection.Syntaxftp_ssl_connect(host,port,timeout);Parametershost − The FTP server address. Can be a domain address or an IP address.port − The port to connect to. Here the default is 21.timeout − The timeout for network operations.ReturnThe ftp_ssl_connect() function returns a SSL-FTP stream on success or FALSE on error.ExampleThe following is an example −