George John has Published 1081 Articles

Abstract Base Classes in Python (abc)

George John

George John

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

11K+ Views

A class is called an Abstract class if it contains one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and its abstract methods must be implemented by its subclasses.Abstract base classes provide a way to ... Read More

MySQL CAST as DATE?

George John

George John

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

528 Views

There is no difference between cast as Date and date() function in MySQL.The syntax of both cast() and date() is as follows −cast(yourDateTimeColumnName as Date) date(yourDateTimeColumnName)Both functions internally call Item_date_typecast. To check both the functions, let us create a table. The query to create a table is as follows −mysql> ... Read More

Python Garbage Collector interface (gc)

George John

George John

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

270 Views

Automatic garbage collection is one of the important features of Python. Garbage collector mechanism attempts to reclaim memory occupied by objects that are no longer in use by the program.Python uses reference counting mechanism for garbage collection. Python interpreter keeps count of number of times an object is referenced by ... Read More

Sum values of a single row in MySQL?

George John

George John

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

1K+ Views

You can use below syntax to sum values of a single row −Case 1 − The following is the syntax if your column does not have NULL value −SELECT yourColumnName1+yourColumnName2+yourColumnName3+.......+N as anyVariableName FROM yourTableName;Case 2 − If your column has NULL value then use this syntax −SELECT IFNULL(yourColumnName1, 0)+ IFNULL(yourColumnName2, ... Read More

MySQL's now() +1 day?

George John

George John

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

6K+ Views

The statement now()+1 day itself states that we need to add a day to the current datetime. You can write the above logic like this −now()+interval 1 day;Or you can write same logic with date_add() function from MySQL like this −date_add(now(), interval 1 day);Let us use the above concept with ... Read More

How to resolve the MySQL error “You have an error in your SQL syntax; check the manualthat corresponds to your MySQL server version for the right syntax to use near?”

George John

George John

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

4K+ Views

To avoid this type of error in MySQL stored procedure, you need to change the delimiter ; to //.Suppose if you are using stored procedure or triggers or even function then you need to change the delimiter. The syntax is as follows.DELIMITER // CREATE PROCEDURE yourProcedureName() ... Read More

Performing a MySQL LIKE comparison on an INT field?

George John

George John

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

723 Views

You need to use cast() method to perform comparison on an INT field. The syntax is as follows −SELECT yourColumnName1, yourColumnName2, ......N yourTableName WHERE CAST(yourColumnName as CHAR) LIKE ‘%yourIntegerValue%’;To understand the above syntax, let us create a table. The following is the query to create a table for performing a ... Read More

Should I use COUNT(*) to get all the records in MySQL?

George John

George John

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

161 Views

Whenever you want all the values like not null for a column then use count(*). This is faster than using count() method.The syntax to use count(*) is as follows −select count(*) as anyVariableName from yourTableName;To understand the above concept, let us first create a table. The query to create a ... Read More

Simple Android grid example using RecyclerView with GridLayoutManager

George John

George John

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

923 Views

Before getting into grid Layout manager for recycler view example, we should know what is Recycler view in android. Recycler view is more advanced version of list view and it works based on View holder design pattern. Using recycler view we can show grids and list of items.This example demonstrate ... Read More

Does MySQL Boolean “tinyint(1)” holds values up to 127?

George John

George John

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

913 Views

Let us learn some points about TINYINT type in MySQL −The TINYINT type takes 1 byte i.e. 8 bits.The TINYINT(N), where N indicates the display width you want.For example, TINYINT(1) can be used to display width which is 1.Let us learn about the minimum and maximum values −The maximum value ... Read More

Advertisements