Concatenate All Values of a Single Column in MySQL

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

1K+ Views

You can use group_concat() along with concat() to concatenate all values of a single column. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20) ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName) values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(FirstName) values('Larry'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(FirstName) values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(FirstName) values('Robert'); ... Read More

Wrap Text in JTextPane and Show Scrollbar in Java

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

2K+ Views

Let’s say we have lots of content in our JTextPane component −textPane.setText("This is demo text1. This is demo text2. This is demo text3."    + "This is demo text4.This is demo text5. This is demo text6. "    + "This is demo text7. This is demo text8. This is demo text9. "    + "This is demo text10. This is demo text11. This is demo text12."    + "This is demo text13. This is demo text13. This is demo text14."    + "This is demo text15. This is demo text13. This is demo text16."    + " This is demo ... Read More

Validate EditText Input in Android

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

1K+ Views

This example demonstrate about How can I validate EditText input in Android.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/ValidateFilter.javapackage app.tutorialspoint.com.sample ; import android.text.InputFilter ; import android.text.Spanned ; import android.util.Log ; import java.util.regex.Matcher ; import java.util.regex.Pattern ; public class ValidateFilter implements InputFilter {    @Override    public CharSequence filter (CharSequence source , int start , int end , Spanned dest ,    int ... Read More

Sort and Group in One MongoDB Aggregation Query

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

796 Views

For sorting and grouping in a single query, use the $group operator along with aggregate framework. Let us first create a collection with documents −> db.sortAndGroupDemo.insertOne({    Price :40,    Product: 10 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce8f2bc78f00858fb12e907") } > db.sortAndGroupDemo.insertOne({    Price :100,    Product: 10 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce8f2bc78f00858fb12e908") } > db.sortAndGroupDemo.insertOne({    Price :90,    Product: 20 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce8f2bc78f00858fb12e909") } > db.sortAndGroupDemo.insertOne({    Price :200,    Product: 10 }); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce8f2bc78f00858fb12e90a") } ... Read More

Skip Column Name While Inserting Values in MySQL

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

804 Views

Yes, we can do that. Let us first create a table −mysql> create table DemoTable    -> (    -> StudentName varchar(100),    -> StudentAge int    -> ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentAge) values(23); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable(StudentName) values('John'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output. NULL will get inserted for the skipped column values −+-------------+------------+ | StudentName | StudentAge ... Read More

HTML DOM Input URL Type Property

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

156 Views

The HTML DOM Input URL type property returns/sets type of Input URL.SyntaxFollowing is the syntax −Returning string valueinputURLObject.typeSetting type to string valueinputURLObject.type = stringValueString ValuesHere, “stringValue” can be the following −stringValueDetailsemailIt defines that input type is emailurlIt defines that input type is urlradioIt defines that input type is radiotelIt defines that input type is tel and a number keypad is shown for inputExampleLet us see an example for Input URL type property − Live Demo Input URL type    form {       width:70%;       margin: 0 auto;       text-align: center;    }   ... Read More

Find Size of Text Stored in a Specific MySQL Column

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

249 Views

You can use length() from MySQL to find the size of text stores in a specific column. Let us first create a tablemysql> create table DemoTable    (    CustomerName longtext    ); Query OK, 0 rows affected (0.67 sec)Insert records in the table using insert command −mysql> insert into DemoTable values('Robert'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output−+--------------+ | CustomerName | +--------------+ | Robert       | +--------------+ 1 row in set (0.00 sec)Here is the query to find the size ... Read More

Decrease Record Value to Zero in MySQL

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

159 Views

Use SET to decrease the value and WHERE to set the condition for a specific record to be 0. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Number int ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command &minusmysql> insert into DemoTable(Number) values(10); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Number) values(20); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Number) values(1); Query OK, 1 row affected ... Read More

Define Min and Max Value for EditText in Android

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

3K+ Views

This example demonstrate about How to define a MIN and MAX value for EditText in Android.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/MinMaxFilter.javapackage app.tutorialspoint.com.sample ; import android.text.InputFilter ; import android.text.Spanned ; public class MinMaxFilter implements InputFilter {    private int mIntMin , mIntMax ;    public MinMaxFilter ( int minValue , int maxValue) {       this . mIntMin = minValue ... Read More

MongoDB Query to Find Documents with Two Values in an Array

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

336 Views

For this, use $elemMatch operator. Let us first create a collection with documents −> db.findDocumentsHaving2Demo.insertOne(    {_id : 101, Values: [78, 98]} ); { "acknowledged" : true, "insertedId" : 101 } > db.findDocumentsHaving2Demo.insertOne(    {_id :102, Values : [89, 102]} ); { "acknowledged" : true, "insertedId" : 102 }Following is the query to display all documents from a collection with the help of find() method −> db.findDocumentsHaving2Demo.find().pretty();This will produce the following output −{ "_id" : 101, "Values" : [ 78, 98 ] } { "_id" : 102, "Values" : [ 89, 102 ] }Following is the query to find documents ... Read More

Advertisements