MySQL select distinct rows into a comma delimited list column?

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

807 Views

You can achieve it with the help of GROUP_CONCAT() function. The syntax is as follows −SELECT yourColumnName1, yourColumnName2, yourColumnName3, ..N, GROUP_CONCAT(yourColumnName4) as anyAliasName FROM yourTableName group by yourColumnName3, yourColumnName1, yourColumnName2;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table CommaDelimitedList    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(10),    -> GroupId int,    -> CompanyName varchar(15),    -> RefId int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using INSERT command. ... Read More

Left justify output in Java

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

2K+ Views

Including a minus sign after the %, makes it left justified.Note − By default, output is right justifiedFirstly, create a formatter object −Formatter f = new Formatter();Now, use the format() method to left justify output −f.format("|%-15.5f|", 299.675796)The following is an example −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { Formatter f = new Formatter(); // left justify f = new Formatter(); System.out.println(f.format("|%-15.5f|", 299.675796)); } }Output|299.67580 |

MySQL date format DD/MM/YYYY select query?

George John
Updated on 30-Jul-2019 22:30:24

2K+ Views

Format the date DD/MM/YYYY using select and order by in descending order. The syntax is as follows −SELECT *FROM yourTableName where yourDatetimeColumnName order by STR_TO_DATE(yourDatetimeColumnName, ’%d/%m%Y’) desc;The above syntax will give the date in descending order. To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table DateFormatWithSelect    -> (    -> UserId int,    -> UserName varchar(100),    -> UserLoginDatetime varchar(100)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert ... Read More

Appending data to a MySQL field that already has data in it?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

4K+ Views

You can append data to a MySQL database field with the help of in-built CONCAT() function.The syntax is as follows −update yourTableName set yourColumnName = CONCAT(yourColumnName, ’AppendValue’);To understand the above concept, let us create a table. The query to create a table −mysql> create table AppendingDataDemo −> ( −> FirstNameAndLastName varchar(200) −> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table with the help of insert command. The query is as follows −mysql> insert into AppendingDataDemo values('John'); Query OK, 1 row affected (0.27 sec) mysql> insert ... Read More

Remove all the elements from an ArrayList that are in another Collection in Java

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

98 Views

The method java.util.ArrayList.removeAll() removes all the the elements from the ArrayList that are available in another collection. This method has a single parameter i.e. the Collection whose elements are to be removed from the ArrayList.A program that demonstrates this is given as followsExample Live Demoimport java.util.ArrayList; import java.util.List; public class Demo { public static void main(String args[]) throws Exception { List aList1 = new ArrayList(); aList1.add("Anna"); aList1.add("John"); aList1.add("Mary"); ... Read More

Who was Cinderella and what's the story behind her shoes?

Knowledge base
Updated on 30-Jul-2019 22:30:24

2K+ Views

Cinderella was the fictional character of a folktale which has a varied version of stories of which the popular version was published by Charles Perrault. This story says that nothing is impossible with graciousness and simple heart.The StoryCinderella is a simple girl born in a wealthy family who lost her mother at a tender age. But her father has little concern towards her. He marries a lady who is very arrogant and haughty. Cinderella’s stepmother treats her like a slave and puts her in servitude. She has two daughters who are equally unkind and disdainful as their mother.Cinderella is made ... Read More

How to give dynamic height to UIlabel programmatically in swift?

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

3K+ Views

To give a dynamic height to an UIlabel in swift we can use the frame property of UILabel. We can create a frame using the CGRect which allows us to give different variables like x position, y position, width, and height.Let’s create a label and add it as a subview to our view.let label = UILabel() label.frame = CGRect(x: 10, y: 40, width: 200, height: 50) label.backgroundColor = colorLiteral(red: 0.7450980544, green: 0.1568627506, blue: 0.07450980693, alpha: 1) label.textColor = colorLiteral(red: 0.05882352963, green: 0.180392161, blue: 0.2470588237, alpha: 1) label.text = "Custom label" self.view.addSubview(label)We can embed this in a function as well, and ... Read More

What is the height of marketing?

Joshi Malvika
Updated on 30-Jul-2019 22:30:24

185 Views

This is absolutely true that marketers are crossing all borders to not only sell their products but also to have an upper hand over their competitors. You look around and observe that their eyes are everywhere and they won’t even hesitate to have a sneak peek into your bedroom if they get a chance. Recently, I was scrolling down my social media account and came across this exceptional way of marketing and thought of sharing with you. Just have a look at these side-splitting advertising efforts.

What are the requirements to become a Public Relations Officer?

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

313 Views

Public relations officers also known as public relations or communications specialists, facilitate relations between organizations and the public. They may work for corporations, non-profit groups, or government agencies.Requirements To Become A Public Relations OfficerDegree: One does not usually need a very high-level degree. A foundation level degree is acceptable. MBA is a huge add-on, although.Start Low: One may start as a public assistant, and then become Public relations officer.Confidence: A qualification in such professions would be Confidence and self-motivational skills. These do come under the banner of soft skills, which are a necessity in this field.Excellent Communication Skills: If one ... Read More

What are the famous cuisines of Delhi?

Tejas Charukula
Updated on 30-Jul-2019 22:30:24

203 Views

Delhi, the capital city of India is known for its delicacies. Most of the dishes are influenced by Mughals and this was the place that gave birth to Mughlai cuisine. There is no one particular cuisine that is identified as the taste of Delhi. A large variety of dishes like different varieties of paranthas, kababs, tandoori, Punjabi, and varieties of chats are relished in Delhi.ParanthasThis is a household food in Delhi and is a perfect meal for common people on the streets as well as hungry college students. This is just a roti type of bread but the difference is ... Read More

Advertisements