Treat MySQL LONGTEXT as Integer in MySQL Query

AmitDiwan
Updated on 26-Feb-2020 05:02:08

305 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Value longtext    -> ); Query OK, 0 rows affected (0.94 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('778437437447488487476464644433334'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('9998888485775775757577578585'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('8888874757757757757757575675656'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('988757757574646'); Query OK, 1 row affected (0.09 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will produce the following ... Read More

Characteristics of a Module in Java 9

raja
Updated on 26-Feb-2020 05:01:28

340 Views

The module is a collection of code, data, and resources. It is a set of related packages and types like classes, abstract classes, and interfaces with code, data files, and some static resources.Below are some of the characteristics of a module.Characteristics of a module:A module must define an interface for communication with other modules.A module defines the separation between a module interface and module implementation.A module presents a set of properties that contains information.Two or more modules have nested together.A module has a clear, defined responsibility. Each function implemented by only one module.A module must able to tested independently from other modules.An error in a module can't propagate to other ... Read More

What Happens When Running SELECT WHERE ColumnName = 0 in MySQL

AmitDiwan
Updated on 25-Feb-2020 13:21:35

117 Views

The following syntax will fetch all the values from the column −select * from yourTableName where yourColumnName=0;Let us first create a table −mysql> create table DemoTable1791      (      FirstName varchar(20)      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1791 values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1791 values('John'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1791 values('Carol'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1791;This ... Read More

MySQL Query to Fetch Records from a Range of Months

AmitDiwan
Updated on 25-Feb-2020 13:19:16

189 Views

Let us first create a table −mysql> create table DemoTable1795      (      Name varchar(20),      DueDate date      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1795 values('John', '2018-07-21'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1795 values('Sam', '2019-10-21'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1795 values('Sam', '2019-01-10'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1795 values('Mike', '2018-12-31'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> ... Read More

Auto Increment After Deleting Data from MySQL Table

AmitDiwan
Updated on 25-Feb-2020 13:18:07

750 Views

For this, you can use TRUNCATE TABLE command. Let us first create a table −mysql> create table DemoTable1796      (      StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,      StudentName varchar(20)      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1796(StudentName) values('Chris Brown'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1796(StudentName) values('David Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1796(StudentName) values('John Doe'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statementmysql> select ... Read More

Fetch Records After a Specific Date in Different Format Using Unix Timestamp in MySQL

AmitDiwan
Updated on 25-Feb-2020 13:12:18

316 Views

For this, you can use STR_TO_DATE(), since we have date records in the following format: 21/11/2019.Let us first create a table −mysql> create table DemoTable1808      (      AdmissionDate varchar(20)      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1808 values('21/11/2019'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1808 values('01/01/2018'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1808 values('26/09/2017'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1808;This will ... Read More

Update MySQL Table Column by Matching Date Using DATE Function

AmitDiwan
Updated on 25-Feb-2020 13:08:00

494 Views

Following is the syntax to match date with date() function and updating a column −update yourTableName set yourColumnName=yourValue where date(yourColumnName)=curdate();Let us first create a table −mysql> create table DemoTable1816      (      Name varchar(20),      JoiningDate datetime      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1816 values('Chris', '2019-11-29 12:34:50'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1816 values('David', '2019-11-30 11:00:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1816 values('Mike', '2018-11-30 10:20:30'); Query OK, 1 row affected (0.00 sec)Display ... Read More

Fetch Number of People Registering on Current Date with MySQL

AmitDiwan
Updated on 25-Feb-2020 13:06:28

172 Views

For this, you can use COUNT() along with GROUP BY MONTH(). To match with the current date, use CURRENT_DATE(). The current date is as follows −mysql> select curdate() ; +------------+ | curdate()  | +------------+ | 2019-11-30 | +------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable1819      (      Name varchar(20),      RegisteringDate datetime      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1819 values('Chris', '2019-11-29 12:30:34'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1819 ... Read More

Check for Null or Empty Variable in MySQL Stored Procedure

AmitDiwan
Updated on 25-Feb-2020 13:02:51

6K+ Views

To check for NULL or empty variable, use the IF condition. Let us create a stored procedure −mysql> delimiter // mysql> create procedure checkingForNullDemo(Name varchar(20))      begin      if Name is NULL OR Name='' then      select 'Adam Smith';      else      select Name;      end if ;      end      // Query OK, 0 rows affected (0.00 sec) mysql> delimiter ;Case 1When NULL is passed. Call the stored procedure using call commandmysql> call checkingForNullDemo(NULL);This will produce the following output −+------------+ | Adam Smith | +------------+ | Adam Smith | +------------+ 1 ... Read More

Multiple Inheritance Using Interfaces in Java

mkotla
Updated on 25-Feb-2020 12:33:24

2K+ Views

Java does not support multiple inheritance. This means that a class cannot extend more than one class. Therefore, following is illegal −Examplepublic class extends Animal, Mammal{}However, a class can implement one or more interfaces, which has helped Java get rid of the impossibility of multiple inheritance.The extends keyword is used once, and the parent interfaces are declared in a comma-separated list.For example, if the Hockey interface extended both Sports and Event, it would be declared as −Examplepublic interface Hockey extends Sports, Event

Advertisements