Perform MongoDB Array Concatenation to Concatenate Records

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

147 Views

For array concatenation, use $concatArrays operator. Let us first create a collection with documents −>db.arrayConcatenationDemo.insertOne({"TeacherName":["Chris", "Robert"], "StudentName":["Mike", "Sam"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce921c078f00858fb12e911") }Following is the query to display all documents from a collection with the help of find() method −> db.arrayConcatenationDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5ce921c078f00858fb12e911"),    "TeacherName" : [       "Chris",       "Robert"    ],    "StudentName" : [       "Mike",       "Sam"    ] }Following is the query for array concatenation −> db.arrayConcatenationDemo.aggregate([    { "$project": {       ... Read More

Count Duplicate Values from a Single Column in MySQL

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

225 Views

Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(10); Query OK, ... Read More

HTML DOM Input Week DefaultValue Property

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

135 Views

The Input Week defaultValue property sets/returns the default value corresponding to Week Input. The value attribute changes as the user resets the week input but default value does not change.SyntaxFollowing is the syntax −Returning string valueinputWeekObject.defaultValueSetting defaultValue to stringinputWeekObject.defaultValue = ‘string’ExampleLet us see an example for Input Week defaultValue property − Live Demo Input Week defaultValue    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px; ... Read More

Print a Long Int in C Using putchar Only

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

2K+ Views

Here we will see how to print long int value using the putchar() function in C. We can easily print the value of some variables using printf() in C, but here the restriction is, we cannot use any other function except putchar().As we know that the putchar() is used to print only characters. We can use this function to print each digit of the number. When one numeric value is passed, we have to add character ‘0’ with it to get the ASCII form. Let us see the code to get the better idea.Example#include void print_long(long value) {   ... Read More

Java SQL Date toString() Method with Example

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

6K+ Views

The toString() method of the java.sql.Date class returns the JDBC escape format of the time of the current Date object as String variable.i.e. using this method, you can convert a Date object to a String.//Retrieving the Date object Date dateObj = rs.getDate("DispatchDate"); //Converting the Date object to String format String date = dateObj.toString();ExampleLet us create a table with name dispatches in MySQL database using CREATE statement as follows −CREATE TABLE dispatches(    ProductName VARCHAR(255),    CustomerName VARCHAR(255),    DispatchDate date,    DeliveryTime time,    Price INT,    Location VARCHAR(255));Now, we will insert 5 records in dispatches table using INSERT statements ... Read More

MySQL System Variable Table Type Issues

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

100 Views

The variable table_type doesn’t work since this variable is deprecated as of MySQL 5.5.3. Use default_storage_engine instead. Following is the syntax −SET default_storage_engine = yourTableEngine;The table engine name may be InnoDB or MyISAM. Here, we will set engine type to MyISAM −mysql> SET default_storage_engine=MyISAM; Query OK,  0 rows affected (0.00 sec)Let us create a table.mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY ); Query OK,  0 rows affected (0.40 sec)Now check the engine type of above table −mysql> SHOW TABLE STATUS WHERE Name = 'DemoTable';This will produce the following output −+--------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | Name | Engine | ... Read More

Validate TextField Inputs in Swift

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

2K+ Views

How often you develop an application and you write same validation for every input fields. One such example is User registration, Login screen or Registration screen or any other screen. It becomes tedious to write same line of code for every input field moreover you may tend to mistake the same.As per the design it is never recommend to write validation for each field, rather you should be writing generic validation functions.So in this blog we will be writing generic validation library of input Text Fields.Advantages of writing genetic validation library.Reuse able code for all functions.Chances of human error getting ... Read More

Make Android Device Vibrate Programmatically

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

741 Views

This example demonstrate about How to make an Android device vibrate programmatically.Step 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.java     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.sample ; import android.content.Context ; import android.os.Build ; import android.os.Bundle ; import android.os.VibrationEffect ; import android.os.Vibrator ; import android.support.v7.app.AppCompatActivity ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;     ... Read More

Find Documents Where All Elements of an Array Have a Specific Value in MongoDB

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

152 Views

You can use find() for this. Let us first create a collection with documents −> db.findDocumentsDemo.insertOne(    {       _id: 101,       "ProductDetails": [          { "ProductValue":100 },          { "ProductValue":120 }       ]    } ); { "acknowledged" : true, "insertedId" : 101 } > db.findDocumentsDemo.insertOne(    {       _id: 102,       "ProductDetails": [          { "ProductValue":120},          { "ProductValue":120 },          { "ProductValue":120 }       ]    } ); { "acknowledged" ... Read More

Search Between Comma-Separated Values Within One Field

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

164 Views

Instead of IN(), use FIND_IN_SET to search between comma separated values within one field. Let us first create a table −mysql> create table DemoTable -> ( -> ListOfValues text -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('10|20|30|40|50|60|100'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-----------------------+ | ListOfValues | +-----------------------+ | 10|20|30|40|50|60|100 ... Read More

Advertisements