AmitDiwan has Published 10744 Articles

Initialization of local variable in a conditional block in Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:14:59

375 Views

Java compiler doesn’t allow abandoning an uninitialized local variable. When a local variable is initialized inside a conditional block, there are 3 possibilities that could potentially occur −Code compiles successfully if values are provided in the conditional block and the given condition is true.Code gives a compilation error if variables ... Read More

Implementing Checksum Using Java

AmitDiwan

AmitDiwan

Updated on 04-Jul-2020 08:09:40

2K+ Views

Following is the code to implement Checksum using Java −Example Live Demoimport java.util.*; public class Demo{    public static void main(String args[]){       Scanner my_scan = new Scanner(System.in);       System.out.println("Enter the input string ");       String my_in = my_scan.next();       int my_checksum = ... Read More

MySQL query to count records that begin with specific letters

AmitDiwan

AmitDiwan

Updated on 03-Jul-2020 12:02:02

365 Views

Let us first create a table −mysql> create table DemoTable775 ( FirstName varchar(100) ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command −mysql> insert into DemoTable775 values('Adam') ; Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable775 values('Carol'); Query OK, 1 ... Read More

Difference Between MySql <> NULL and IS NOT NULL?

AmitDiwan

AmitDiwan

Updated on 03-Jul-2020 08:14:18

304 Views

If you compare the operator with NULL value then you will get NULL value always and no result.Let us see some examples for comparison −mysql> select 10 NULL; +------------+ | 10 NULL | +------------+ | NULL       | +------------+ 1 row in set (0.00 sec) ... Read More

How to update records in a column with random numbers in MySQL?

AmitDiwan

AmitDiwan

Updated on 03-Jul-2020 07:24:13

295 Views

Let us first create a table −mysql> create table DemoTable746 (    Number int ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable746 values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable746 values(200); Query OK, 1 ... Read More

HTML DOM Anchor search Property

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 14:53:54

147 Views

The HTML DOM search property associated with the anchor tag () returns the query string part of the href property value. The query string part is after the ? in a url and is usually used to pass information to the server. It is used when a get request is ... Read More

Display MySQL histogram with negative values?

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 12:29:23

174 Views

For negative values, use reverse() along with concat(). Let us first create a table −mysql> create table DemoTable632 (    histogramId int NOT NULL AUTO_INCREMENT PRIMARY KEY, histogramValue int, histogramImage text ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

Count occurrences of known distinct values in MySQL

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 12:25:57

220 Views

For this, you can use aggregate function SUM(). Let us first create a table −mysql> create table DemoTable636 (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100) ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable636(StudentFirstName) values('John'); ... Read More

Create a MySQL function and find the average of values in a column

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 12:25:11

384 Views

Let us first create a table −mysql> create table DemoTable638 (Name varchar(100), Marks int); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable638 values('John', 67); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable638 values('John', 90); Query OK, ... Read More

How can I display all databases in MySQL and for each database show all tables?

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 12:00:13

538 Views

For this, you can use INFORMATION_SCHEMA. Following is the syntax −select my_schema.SCHEMA_NAME, group_concat(tbl.TABLE_NAME) from information_schema.SCHEMATA my_schema left join information_schema.TABLES tbl on my_schema.SCHEMA_NAME=tbl.TABLE_SCHEMA group by my_schema.SCHEMA_NAME;Let us implement the above syntax in order to show all databases in MySQL and for each database −mysql> select my_schema.SCHEMA_NAME, group_concat(tbl.TABLE_NAME)    from information_schema.SCHEMATA my_schema ... Read More

Advertisements