Anvi Jain has Published 419 Articles

How can I calculate the total value of products from my MySQL product table?

Anvi Jain

Anvi Jain

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

626 Views

Let us first create a table −mysql> create table DemoTable    (    ProductId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ProductQuantity int,    ProductPrice int    ); Query OK, 0 rows affected (0.19 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ProductQuantity, ProductPrice) values(10, 100); ... Read More

Java DatabaseMetaData getMaxTablesInSelect() method with example.

Anvi Jain

Anvi Jain

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

92 Views

The getMaxTablesInSelect() method of the DatabaseMetaData interface is used to find out the maximum number of tables that the underlying database allows in an SQL SELECT statement.This method returns an integer value, representing the maximum number of tables allowed in a SELECT statement. If this value is 0 it indicates ... Read More

MySQL filtering by multiple columns?

Anvi Jain

Anvi Jain

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

2K+ Views

To perform filtering by multiple columns, use where clause along with OR. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(10),    Score int    ); Query OK, 0 rows affected (0.28 sec)Insert some records in ... Read More

How can I order in group but randomly with MySQL?

Anvi Jain

Anvi Jain

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

371 Views

Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value char(1)    ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value) values('X'); Query OK, 1 row affected ... Read More

How to set all the Arrow Buttons in a frame with Java?

Anvi Jain

Anvi Jain

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

371 Views

To set arrow buttons in a frame, let us first create a frame −JFrame frame = new JFrame();Now, set the layout for the frame wherein all the arrow buttons would be displayed −frame.setLayout(new GridLayout(0, 5));Set the arrow buttons for all the locations −frame.add(new BasicArrowButton(BasicArrowButton.EAST)); frame.add(new BasicArrowButton(BasicArrowButton.NORTH)); frame.add(new BasicArrowButton(BasicArrowButton.SOUTH)); frame.add(new BasicArrowButton(BasicArrowButton.WEST));The ... Read More

New line separator doesn't work for group_concat function in MySQL? How to use it correctly?

Anvi Jain

Anvi Jain

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

2K+ Views

To use new line separator in group_concat() function, follow the below syntax −select group_concat(concat_ws(' ', yourColumnName1, yourColumnName2) SEPARATOR "\r") from yourTableName;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(20),    LastName varchar(20)    ); Query OK, ... Read More

Querying an array of arrays in MongoDB?

Anvi Jain

Anvi Jain

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

942 Views

Use $in operator to query an array of arrays in MongoDB. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.arrayOfArraysDemo.insertOne({"EmployeeName":"Larry", "EmployeeSkills":[["Java", "MongoDB", "MySQL", "SQL Server"]]}); {    "acknowledged" : true,    "insertedId" : ... Read More

Find a document with ObjectID in MongoDB?

Anvi Jain

Anvi Jain

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

352 Views

To find a document with Objectid in MongoDB, use the following syntax −db.yourCollectionName.find({"_id":ObjectId("yourObjectIdValue")}).pretty();To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.findDocumentWithObjectIdDemo.insertOne({"UserName":"Larry"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c90e4384afe5c1d2279d69b") } > ... Read More

How can I use 'Not Like' operator in MongoDB?

Anvi Jain

Anvi Jain

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

1K+ Views

For this, use the $not operator in MongoDB. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.notLikeOperatorDemo.insertOne({"StudentName":"John Doe"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8a29c393b406bd3df60dfc") } > db.notLikeOperatorDemo.insertOne({"StudentName":"John Smith"}); {   ... Read More

How to filter data using where Clause and “IN” in Android sqlite?

Anvi Jain

Anvi Jain

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

226 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to ... Read More

Advertisements