Subtract 30 Days from Current Datetime in MySQL

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

5K+ Views

To subtract 30 days from current datetime, first we need to get the information about current date time, then use the now() method from MySQL. The now() gives the current date time.The method to be used for this is DATE_SUB() from MySQL. Here is the syntax to subtract 30 days from current datetime.The syntax is as follows −DATE_SUB(NOW(), INTERVAL 30 DAY);The above syntax calculates the current datetime first and in the next step, subtracts 30 days. Let us first seethe query to get the current datetime −mysql> select now();Here is the output −+---------------------+ | now() ... Read More

Difference Between MySQL TINYINT(2) and TINYINT(1)

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

2K+ Views

The number 2 and 1 in TINYINT(2) vs TINYINT(1) indicate the display width. There is no difference between tinyint(1) and tinyint(2) except the width.If you use tinyint(2) or even tinyint(1), the difference is the same. You can understand the above concept using zerofill option.tinyint(1) zerofilltinyint(2) zerofillLet us create a table. The query to create a table is as follows −mysql> create table tinyIntDemo    -> (    -> Number1 tinyint(1) zerofill,    -> Number2 tinyint(2) zerofill    -> ); Query OK, 0 rows affected (0.62 sec)Insert record in the table using insert command. The query is as follows −mysql> insert ... Read More

Detect iOS Version Running on the Device

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

545 Views

When working on iOS applications, we sometimes need to know the version that's running on an iPhone device. In this article we'll learn how to find the iOS version being used, using an iOS Application.Create an iOS application and in it's viewController's view did load function write the following code.print(" System version - ",UIDevice.current.systemVersion)This will return the iOS version of the device currently in use. Like current version of my simulator is iOS 12.0 hence the result comes asSystem Version – 12.0

Iterate Through the Values of TreeMap in Java

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

730 Views

Use Iterator and the values() method to iterate through the values of TreeMap.Let us first create a TreeMap and add some elements −TreeMap m = new TreeMap(); m.put(1, "PHP"); m.put(2, "jQuery"); m.put(3, "JavaScript"); m.put(4, "Ruby"); m.put(5, "Java"); m.put(6, "AngularJS"); m.put(7, "ExpressJS");Iterate through the values −Collection res = m.values(); Iterator i = res.iterator(); while (i.hasNext()) {    System.out.println(i.next()); }The following is the complete example to iterate through the values −Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       TreeMap m = new TreeMap();       m.put(1, "PHP");       m.put(2, "jQuery"); ... Read More

Change Collation to utf8_bin in a Single Line

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

173 Views

You need to use ALTER command to change collation to utf8_bin. The syntax is as follows:ALTER TABLE yourTableName COLLATE utf8_general_ci;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table CollateDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(20),    -> Age int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.98 sec)Check the DDL of the table. The syntax is as follows:SHOW CREATE TABLE yourTableName;Let us now check the DDL of our table:mysql> show create table CollateDemo;The following is ... Read More

Show MySQL Warning That Just Happened

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

344 Views

To show a MySQL warning, you can use the below syntax −SHOW WARNINGS;The above syntax only displays the immediate warning from MySQL prompt. Suppose you run another query between them or you have lost the MySQL connection, then SHOW WARNINGS will not work.Here is the query to display warnings −mysql> SHOW WARNINGS;Here is the output that displays immediate warning −+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message ... Read More

Difference Between SQL and MySQL

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

624 Views

SQLSQL is a type of language that can be used to utilize your database. It is a base language for databases like MySQL, SQL Server, Oracle etc. SQL stands for Structure Query Language and it can be used to utilize the relational database management system.This can also be used for accessing, manipulating and updating data in the database using some commands. The SQL commands are as follows −SELECTUPDATE, etc.SQL can also be used in the creation of schema as well as controlling the data access.MySQLMySQL is a relational database management system that utilizes the SQL command. MySQL provides the tools ... Read More

What Would Happen If Earth Started to Rotate in the Opposite Direction

Shanmukh Pasumarthy
Updated on 30-Jul-2019 22:30:24

5K+ Views

Earth rotates around its own axis which is tilted at 23.5 degrees, from the plane of its orbit around the sun, in the eastward direction. It takes almost 24 hours to complete one rotation. The Earth rotates at a speed of 460 m/s, that is approximately 1650 km/hr at the equator. The angular velocity of the Earth decreases as we keep moving toward the poles.The Earth's rotational speed is slowing down with time. According to atomic clocks, the present day is 1.7 milliseconds slower than a century ago. It is not a big issue as it will take more than ... Read More

NavigableMap floorEntry Method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

205 Views

The floorEntry() NavigableMap method returns a key-value mapping associated with the greatest key less than or equal to the given keyThe following is an example to implement floorEntry() method −Example Live Demoimport java.util.*; public class Demo {    public static void main(String[] args) {       NavigableMap n = new TreeMap();       n.put(5, "Tom");       n.put(9, "John");       n.put(14, "Jamie");       n.put(1, "Tim");       n.put(4, "Jackie");       n.put(15, "Kurt");       n.put(19, "Tiger");       n.put(24, "Jacob");       System.out.println("NavigableMap elements..."+n);       System.out.println("Floor Entry = "+n.floorEntry(5));    } }OutputNavigableMap elements... {1=Tim, 4=Jackie, 5=Tom, 9=John, 14=Jamie, 15=Kurt, 19=Tiger, 24=Jacob} Floor Entry 5=Tom

Create MySQL Table from Existing Table

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

471 Views

You can use CREATE TABLE command to create a table from an existing table. The syntax is as follows:CREATE TABLE yourNewTableName LIKE yourOldTableNameTo understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table ShowCreateTableCommand    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> FirstName varchar(20),    -> LastName varchar(20),    -> Age int,    -> TotalMarks int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (1.22 sec)Here is the query to describe a table using DESC command. The query is as follows:mysql> desc ... Read More

Advertisements