Anvi Jain has Published 569 Articles

Simple way to toggle a value of an int field in MySQL

Anvi Jain

Anvi Jain

Updated on 29-Jun-2020 07:52:06

440 Views

To toggle a value of an int field, you can use update command with if(). The syntax is as follows −update yourTableName set yourColumnName = IF(yourColumnName = 0, 1, 0);To understand the above toggle syntax, create a table with some int value. The query to create a table is as ... Read More

How to reset the primary key of a table in mysql?

Anvi Jain

Anvi Jain

Updated on 29-Jun-2020 07:40:36

1K+ Views

The reset the primary key of a table means to reset the auto_increment property to 1. The syntax is as follows to reset the primary key of a table.alter table yourTableName auto_increment = 1;To understand, let us create a table −mysql> create table ResetPrimaryKey −> (    −> Id int ... Read More

How to get timestamp using MySQL?

Anvi Jain

Anvi Jain

Updated on 29-Jun-2020 07:32:46

235 Views

You can get timestamp with the help of current_timestamp, now() and current_timestamp().Case 1 − Using current_timestamp()The query is as follows −mysql> SELECT CURRENT_TIMESTAMP();The following is the output displaying timestamp −+---------------------+ | CURRENT_TIMESTAMP() | +---------------------+ | 2018-11-29 16:09:31 | +---------------------+ 1 row in set (0.00 sec)Case 2 − Using now()The query ... Read More

Get the number of columns in a MySQL table?

Anvi Jain

Anvi Jain

Updated on 29-Jun-2020 07:25:22

605 Views

To get the number of columns, use the aggregate function count(*) with information_schema table from MySQL. The syntax is as follows to find the number of columns −SELECT COUNT(*) as anyVariableName from INFORMATION_SCHEMA.COLUMNS where table_schema = ’yourDatabaseName’ and table_name = ’yourTableName’;To understand the above syntax, let us create a table ... Read More

Move rows from one table to another in MySQL?

Anvi Jain

Anvi Jain

Updated on 29-Jun-2020 07:23:06

4K+ Views

You can move rows from one table to another with the help of INSERT INTO SELECT statement.The syntax is as follows −insert into yourDestinationTableName select *from yourOriginalTable where someConditionTo understand the above syntax. let us create a table. The following is the query to create a table −mysql> create table ... Read More

Sort ArrayList in Descending order using Comparator with Java Collections

Anvi Jain

Anvi Jain

Updated on 29-Jun-2020 06:42:21

5K+ Views

In order to sort ArrayList in Descending order using Comparator, we need to use the Collections.reverseOrder() method which returns a comparator which gives the reverse of the natural ordering on a collection of objects that implement the Comparable interface.Declaration − The java.util.Collections.reverseOrder() method is declared as follows -public static Comparator ... Read More

Create and demonstrate an immutable collection in Java

Anvi Jain

Anvi Jain

Updated on 29-Jun-2020 06:41:47

210 Views

In order to create and demonstrate an immutable collection in Java, we use the unmodifiableCollection() method. This method returns an unmodifiable and immutable view of the collection.Declaration − The java.util.Collections.unmodifiableCollection() method is declared as follows -public static Collection unmodifiableCollection(Collection

Determining If an Object Is an Array in Java

Anvi Jain

Anvi Jain

Updated on 29-Jun-2020 06:38:56

6K+ Views

In order to determine if an object is an Object is an array in Java, we use the isArray() and getClass() methods.The isArray() method checks whether the passed argument is an array. It returns a boolean value, either true or falseSyntax - The isArray() method has the following syntax -Array.isArray(obj)The getClass() ... Read More

Disassembler for Python bytecode

Anvi Jain

Anvi Jain

Updated on 27-Jun-2020 14:24:11

3K+ Views

The dis module in Python standard library provides various functions useful for analysis of Python bytecode by disassembling it into a human-readable form. This helps to perform optimizations. Bytecode is a version-specific implementation detail of the interpreter.dis() functionThe function dis() generates disassembled representation of any Python code source i.e. module, class, method, function, ... Read More

How to determine device type (iPhone, iPod Touch) with iPhone SDK?

Anvi Jain

Anvi Jain

Updated on 27-Jun-2020 13:47:59

497 Views

When working on iOS applications, we sometimes need to know the device on which application is installed, and provide custom features depending on the device in use. For example, we want to provide some features on iPhone X but not on iPhone 7. In this article, we’ll learn how to ... Read More

Previous 1 ... 3 4 5 6 7 ... 57 Next
Advertisements