Questions tagged [concat]

Refers to the joining of two or more elements into a single element.

Concatenation refers to the joining of two or more elements into a single element. In programming, this can refer to string concatenation, which joins multiple strings into a single string, or array concatenation, where one or more arrays are combined(mostly appended) to make a new array. In some cases there are specific concatenation functions that combine elements along a specified dimension (horizontally, or vertically for example), replicate and tile existing elements, and so forth.

2496 questions
3061
votes
29 answers

How to concatenate string variables in Bash

In PHP, strings are concatenated together as follows: $foo = "Hello"; $foo .= " World"; Here, $foo becomes "Hello World". How is this accomplished in Bash?
Strawberry
  • 58,930
  • 53
  • 138
  • 190
1321
votes
11 answers

Can I concatenate multiple MySQL rows into one field?

Using MySQL, I can do something like: SELECT hobbies FROM peoples_hobbies WHERE person_id = 5; My Output: shopping fishing coding but instead I just want 1 row, 1 col: Expected Output: shopping, fishing, coding The reason is that I'm selecting…
Dean Rather
  • 29,230
  • 13
  • 59
  • 68
388
votes
12 answers

Which is the preferred way to concatenate a string in Python?

Since Python's string can't be changed, I was wondering how to concatenate a string more efficiently? I can write like it: s += stringfromelsewhere or like this: s = [] s.append(somestring) later s = ''.join(s) While writing this question, I…
Max
  • 7,227
  • 8
  • 29
  • 38
219
votes
6 answers

Merge two dataframes by index

I have the following dataframes: > df1 id begin conditional confidence discoveryTechnique 0 278 56 false 0.0 1 1 421 18 false 0.0 1 > df2 concept 0 A 1 B How do…
brucezepplin
  • 7,402
  • 18
  • 68
  • 115
195
votes
20 answers

How do I concatenate strings in Swift?

How to concatenate string in Swift? In Objective-C we do like NSString *string = @"Swift"; NSString *resultStr = [string stringByAppendingString:@" is a new Programming Language"]; or NSString *resultStr=[NSString stringWithFormat:@"%@ is a new…
Rajneesh071
  • 29,619
  • 13
  • 57
  • 72
189
votes
7 answers

MySQL CONCAT returns NULL if any field contain NULL

I have following data in my table "devices" affiliate_name affiliate_location model ip os_type os_version cs1 inter Dell 10.125.103.25 Linux Fedora cs2 inter …
neeraj
  • 7,235
  • 16
  • 55
  • 84
186
votes
4 answers

String concatenation in MySQL

I am using MySQL and MySQL Workbench 5.2 CE. When I try to concatenate 2 columns, last_name and first_name, it doesn't work : select first_name + last_name as "Name" from test.student
Roshan
  • 2,054
  • 2
  • 13
  • 12
174
votes
7 answers

SQL UPDATE all values in a field with appended string CONCAT not working

Here is what I want to do: current table: +----+-------------+ | id | data | +----+-------------+ | 1 | max | | 2 | linda | | 3 | sam | | 4 | henry | +----+-------------+ Mystery Query (…
Fresheyeball
  • 28,195
  • 19
  • 94
  • 160
170
votes
8 answers

Adding two Java 8 streams, or an extra element to a stream

I can add streams or extra elements, like this: Stream stream = Stream.concat(stream1, Stream.concat(stream2, Stream.of(element)); And I can add new stuff as I go, like this: Stream stream = Stream.concat( Stream.concat( …
MarcG
  • 21,878
  • 14
  • 83
  • 95
169
votes
5 answers

Concatenate a list of pandas dataframes together

I have a list of Pandas dataframes that I would like to combine into one Pandas dataframe. I am using Python 2.7.10 and Pandas 0.16.2 I created the list of dataframes from: import pandas as pd dfs = [] sqlall = "select * from mytable" for chunk in…
Whitebeard
  • 4,557
  • 5
  • 19
  • 28
141
votes
5 answers

Is there any haskell function to concatenate list with separator?

Is there a function to concatenate elements of a list with a separator? For example: > foobar " " ["is","there","such","a","function","?"] ["is there such a function ?"] Thanks for any reply!
Fopa Léon Constantin
  • 10,665
  • 7
  • 38
  • 73
130
votes
6 answers

Concatenate strings in Less

I think this is not possible, but I thought I ask in case there is a way. The idea is that I have a variable for path to web resource folder: @root: "../img/"; @file: "test.css"; @url: @root@file; .px { background-image: url(@url); } I get…
juminoz
  • 3,240
  • 7
  • 32
  • 48
123
votes
8 answers

Prepend text to beginning of string

What is the fastest method, to add a new value at the beginning of a string?
mate64
  • 8,500
  • 15
  • 58
  • 93
122
votes
7 answers

How to use GROUP_CONCAT in a CONCAT in MySQL

If I have a table with the following data in MySQL: id Name Value 1 A 4 1 A 5 1 B 8 2 C 9 how do I get it into the following format? id Column 1 …
Biswa
  • 1,391
  • 2
  • 10
  • 15
117
votes
6 answers

MySQL select with CONCAT condition

I'm trying to compile this in my mind.. i have a table with firstname and lastname fields and i have a string like "Bob Jones" or "Bob Michael Jones" and several others. the thing is, i have for example Bob in firstname, and Michael Jones in…
Alex K
  • 5,807
  • 7
  • 36
  • 61
1
2 3
99 100