string-concatenation

How to concatenate strings of a string field in a PostgreSQL 'group by' query?

I am going to answer my own question because I just found the answer, but thought it still worth posting here. I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table: ID COMPANY_ID EMPLOYEE 1 1 Anna 2 1 Bill 3 2 Carol 4 2 ...

Why to use StringBuffer in Java instead of the string concatenation operator

Someone told me it's more efficient to use StringBuffer to concatenate strings in Java than to use the + operator for Strings. What happens under the hood when you do that? What does StringBuffer do differently? ...

php: output[] w/ join vs $output .=

I'm modifying some code in which the original author built a web page by using an array thusly: $output[]=$stuff_from_database; $output[]='more stuff'; // etc echo join('',$output); Can anyone think of a reason why this would be preferable (or vice versa) to: $output =$stuff_from_database; $output .='more stuff'; // etc echo ...

PHP HTML generation - using string concatention

A question about different methods of outputting html from PHP; what are the performance differences between these: Method 1 - variable concatenation $html = ''; $html .= '<ul>'; for ($k = 1; $k < = 1000; $k++){ $html .= '<li> This is list item #'.$k.'</li>'; } $html .= '</ul>'; echo $html; Method 2 - output buffering ob_start()...

Using Linq to concatenate strings

What is the most efficient way to write the old-school: StringBuilder sb = new StringBuilder(); if (strings.Count > 0) { foreach (string s in strings) { sb.Append(s + ", "); } sb.Remove(sb.Length - 2, 2); } return sb.ToString(); ...in Linq? ...

Why does addition of long variables cause concatenation?

What does Java do with long variables while performing addition? Wrong version 1: Vector speeds = ... //whatever, speeds.size() returns 2 long estimated = 1l; long time = speeds.size() + estimated; // time = 21; string concatenation?? Wrong version 2: Vector speeds = ... //whatever, speeds.size() returns 2 long estimated = 1l; long ...

refactor HTML-generating JavaScript

Hi, Unfortunately on my project, we generate a lot of the HTML code in JavaScript like this: var html = new StringBuffer(); html.append("<td class=\"gr-my-deals\"><a href=\"").append(deal.url).append("\" target=\"_blank\">").append(deal.description).append("</a></td>"); I have 2 specific complaints about this: The use of escaped do...

How to use GROUP BY to concatenate strings in SQL Server?

How do I get: id Name Value 1 A 4 1 B 8 2 C 9 to id Column 1 A:4, B:8 2 C:9 ...

Concat strings returned from RegQueryValueEx

Hi, I want to read a string value from the registry and concatenate it with another certain string. I'm calling RegQueryValueEx() , like this: Dim lResult As Long Dim sLength As Long Dim sString As String sString = Space$(256) sLength = 256 lResult = RegQueryValueEx(hKey, "MyKey", 0, REG_SZ, ByVal sString, sLength) MsgBox sString & ...

String concatenation vs. string substitution in Python

In Python, the where and when of using string concatenation versus string substitution eludes me. As the string concatenation has seen large boosts in performance, is this (becoming more) a stylistic decision rather than a practical one? For a concrete example, how should one handle construction of flexible URIs: DOMAIN = 'http://stack...

Difference between {$_GET['id']} and '".$_GET['id']."'?

Is the any difference between writing {$_GET['id']} and '".$_GET['id']."' in a sql statement? both works the same ...

T-SQL While Loop and concatenation

I have a SQL query that is supposed to pull out a record and concat each to a string, then output that string. The important part of the query is below. DECLARE @counter int; SET @counter = 1; DECLARE @tempID varchar(50); SET @tempID = ''; DECLARE @tempCat varchar(255); SET @tempCat = ''; DECLARE @tempCatString varchar(5000); SET @t...

How do I concatenate strings in Objective-C?

Are there any shortcuts to (stringByAppendingString:) string concatenation in Objective-C or shortcuts for working with NSString or other objects in general? e.g. I'd like to make this: NSString *myString = @"This"; NSString *test = [myString stringByAppendingString:@" is just a test"]; something more like this: string myString = "T...

Concatenating NSArray contents with NSMutableString AppendString

I'm trying to iterate through an NSArray and keep getting a compiler error right when i try concatenating the contents of my array at position i to my NSMutableString instance.. It just tells me that there's a "syntax error before ;" which doesn't tell me a whole lot. at this line: [output appendString:[widget.children objectAtIndex...

String Concatenation unsafe in C#, need to use StringBuilder?

My question is this: Is string concatenation in C# safe? If string concatenation leads to unexpected errors, and replacing that string concatenation by using StringBuilder causes those errors to disappear, what might that indicate? Background: I am developing a small command line C# application. It takes command line arguments, performs...

String.Format vs "string" + "string" or StringBuilder?

Possible Duplicates: Is String.Format as efficient as StringBuilder C# String output: format or concat? What is the performance priority and what should be the conditions to prefer each of the following: String.Format("{0}, {1}", city, state); or city + ", " + state; or StringBuilder sb = new StringBuilder(); sb.Append(...

Concat groups in SQL Server

If I have a table like this: +------------+ | Id | Value | +------------+ | 1 | 'A' | |------------| | 1 | 'B' | |------------| | 2 | 'C' | +------------+ How can I get a resultset like this: +------------+ | Id | Value | +------------+ | 1 | 'AB' | |------------| | 2 | 'C' | +------------+ I know this is really easy ...

Combine Multiple Fields into One Text Field in SQL Server

So I have a table that looks like this: Name ID TaskID HoursAssigned ---------------------------------------------------------------- John Smith 4592 A01 40 Matthew Jones 2863 A01 20 Jake Adams 1182 A01 100 Matth...

What would be the best way to use string functions and alteration on one string?

What should be the best way to write code: 1) Dim current = Request.Path current = current.Remove(0, 1) current = current.Replace(".aspx", "") 2) Dim current = Request.Path.Remove(0, 1).Replace(".aspx", "") 3) Dim current = Request.Path Dim current2 = current.Remove(0, 1) Dim current3 = current.Replace(".aspx", "") Or 1-2 mak...

collecting numbers and printing them

so what I'm trying to accomplish is generating 100 random 0's and 1's add them all into one variable and then print it. What I have right now I don't know how to make work. If someone could explain what I'm doing wrong, I would be very grateful. randstring (void){ int i; int num; char buffer[101]; i=100; while(i>0, i...