Count boolean field values within a single MySQL query?

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

2K+ Views

To count boolean field values within a single query, you can use CASE statement. Let us create a demo table for our example −mysql> create table countBooleanFieldDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentFirstName varchar(20),    -> isPassed tinyint(1)    -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into countBooleanFieldDemo(StudentFirstName, isPassed) values('Larry', 0); Query OK, 1 row affected (0.12 sec) mysql> insert into countBooleanFieldDemo(StudentFirstName, isPassed) values('Mike', 1); Query OK, 1 row affected (0.17 sec) mysql> insert into ... Read More

C++ Program to Check if a Binary Tree is a BST

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

1K+ Views

Binary Search Tree is a binary tree data structure in which we have 3 properties −The left subtree of a binary search tree of a node contains only nodes with keys lesser than the node’s key.The right subtree of a binary search tree node contains only nodes with keys greater than the node’s key.The left and right of a subtree each must also be a binary search tree.AlgorithmBegin    function BSTUtill()       If node is equals to NULL then          Return 1.       If data of node is less than minimum or greater ... Read More

How to add dividers and spaces between items in RecyclerView?

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

3K+ Views

This example demonstrate about How to add dividers and spaces between items in RecyclerViewStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                   In the above code, we have taken recycerview.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.TargetApi; import android.os.Build; import android.os.Bundle; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.widget.TextView; import android.widget.Toast; import ... Read More

Insert an element to List using ListIterator in Java

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

341 Views

Let us first create an ArrayList −ArrayList < Integer > arrList = new ArrayList < Integer > (); arrList.add(100); arrList.add(200); arrList.add(300); arrList.add(400); arrList.add(500);Now, create a ListIterator from the above ArrayList and insert more elements −ListIterator < Integer > iterator = arrList.listIterator(); iterator.add(1000); iterator.add(2000); iterator.add(3000);Example Live Demoimport java.util.ArrayList; import java.util.ListIterator; public class Demo {    public static void main(String[] args) {       ArrayListarrList = new ArrayList();       arrList.add(100);       arrList.add(200);       arrList.add(300);       arrList.add(400);       arrList.add(500);       arrList.add(600);       arrList.add(700);       arrList.add(800);     ... Read More

How to initialize private static members in C++?

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

24K+ Views

Here we will see how to initialize the private static member variables initialization in C++. We can put static members (Functions or Variables) in C++ classes. For the static variables, we have to initialize them after defining the class.To initialize we have to use the class name then scope resolution operator (::), then the variable name. Now we can assign some value.The following code will illustrate the of static member initializing technique.Example#include using namespace std; class MyClass{    private:       static int st_var;    public:       MyClass(){          st_var++; //increase the value ... Read More

Is Flutter a stable platform to develop cross platform application?

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

248 Views

Flutter is an open source mobile app development kit from Google. It works with the existing code and is an excellent SDK (Software Development Kit) to develop iOS and Android programs. It is cost effective and eases the complexity of developing iOS and Android apps. It is primarily used for creating an application in Google Fuchsia.The main advantage of Flutter is that a lot of code can be shared between platforms. Without writing platform-specific code, the developers can use it to develop applications for Android and iOS alike. Being an Open source SDK, it makes every application look like a ... Read More

How to print julianday in Android sqlite?

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

179 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 access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to print julianday in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create ... Read More

How to write a JDBC program to extract data from multiple databases?

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

1K+ Views

To connect with a data base, you need toRegister the DriverSelect the required database register the Driver class of the particular database using the registerDriver() method of the DriverManager class or, the forName() method of the class named Class.DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get connectionCreate a connection object by passing the URL of the database, username and password of a user in the database (in string format) as parameters to the getConnection() method of the DriverManager class.Connection mysqlCon = DriverManager.getConnection(mysqlUrl, "root", "password");And, to extract data you need to execute the select query as:ResultSet rs = stmt.executeQuery("Select * from Employee");To print the contents of the ... Read More

Check if a field contains a string in MongoDB?

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

2K+ Views

You can use $regex operator to check if a field contains a string in MongoDB. The syntax is as follows −db.yourCollectionName.findOne({"yourFieldName":{$regex:".*yourValue.*"}});To understand the above concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.checkFieldContainsStringDemo.insertOne({"Id":1, "Name":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c77d762fc4e719b197a12ed") } > db.checkFieldContainsStringDemo.insertOne({"Id":2, "Name":"Johnson"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c77d76bfc4e719b197a12ee") } > db.checkFieldContainsStringDemo.insertOne({"Id":3, "Name":"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c77d774fc4e719b197a12ef") } > db.checkFieldContainsStringDemo.insertOne({"Id":4, "Name":"Mike"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c77d77cfc4e719b197a12f0") } > db.checkFieldContainsStringDemo.insertOne({"Id":5, "Name":"Sam"}); ... Read More

Add to existing value in MySQL column using CONCAT function?

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

950 Views

To understand the concept, let us first create a demo table.mysql> create table addToExistingValueDemo    -> (    -> Instructor_Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Instructor_Name varchar(30),    -> Instructor_TechnicalSubject text    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into addToExistingValueDemo(Instructor_Name, Instructor_TechnicalSubject) values('John', 'C, C++'); Query OK, 1 row affected (0.15 sec) mysql> insert into addToExistingValueDemo(Instructor_Name, Instructor_TechnicalSubject) values('Carol', 'Java, Python'); Query OK, 1 row affected (0.18 sec) mysql> insert into addToExistingValueDemo(Instructor_Name, Instructor_TechnicalSubject) values('Bob', 'MySQL, SQL Server'); Query OK, 1 row ... Read More

Advertisements