Questions tagged [concat]

In formal language theory and computer programming, string concatenation is the operation of joining two character strings end-to-end

Filter by
Sorted by
Tagged with
6
votes
2answers
434 views

NULL value causes blank row in SELECT results for text concatenation

I have a query for producing some text for creating some VALUES text to put in a .sql file for inserting some rows. I get a blank line in the results: postgres=# SELECT ' (' || obj_id || ', ''' || ...
0
votes
1answer
20 views

How to use query result as REPLACE parameters

i'm trying to: 1- Find a string inside a lot of content 2- Replace that specific part of the string with a new one using REPLACE function like this: REPLACE(column_name, query#1, query#2) Is this ...
0
votes
1answer
14 views

Postgresql Date Function Returning Range In Readable Format

I am wondering if it is possible to use postgresql's date-time , concat and case functions to give one of the following results: June 4th to 11th 2019 (where the 1st and 2nd date are within the same ...
0
votes
0answers
53 views

Sql subquery for nested parent child data

I have two tables , on parent table (categories ) and child table (features).. I have this query select c.* , (select GROUP_CONCAT(f.featuresId , f.featuresTitle ) from ...
0
votes
0answers
23 views

How performant is finding a substring in database?

To route requests on my website, I need to query the database to see if the first part of a URL matches a category for an item. For example: I have a request to /animals/dog/darktheme/. The ...
3
votes
1answer
140 views

Large string concatenation in query

I am trying to concatenates strings in T-SQL like 'This is a test ' + CHAR(13) + CHAR(10) + ' string' When the string is long (I do not know the limit), I get an error: Some part of your SQL ...
0
votes
1answer
64 views

CONCAT_WS causes “Data too long” which works partially?

I've got a simple table with several columns and I'm trying to merge two of them into one. I'm working with MySQL 5.5 and I can reproduce the error one a specific data set by running the following (...
2
votes
2answers
97 views

How can the concatenatation of a text and a NULL value return a non-null result?

Assert 1 The concatenation operator || can concatenate any string type values, returning text. In Postgres, every type has a text representation and can be cast to text. Consequently, quoting the ...
2
votes
2answers
161 views

How to Concat Datetime without Losing Second Precision

What is best way to Concat on datetime column with other fields, without losing/truncate millisecond precision? Example: We have a column in datetime precision. 1988-02-27 00:00:04.000 We are ...
-3
votes
1answer
799 views

Updating a string field by concatenating 2 int columns

I have 2 columns, an int and a tiny int, and I want to update another column, a varchar one, with the value column1 + '-' + column2. Something like this pseudo code: UPDATE COLUMN3 varchar = CONCAT (...
0
votes
1answer
747 views

Concatenate into Field in Update

I am trying to write a Stored Procedure which updates a quantity data column in one of my tables, and then takes a field set for random notes and concatenates the update information. This is what I ...
1
vote
1answer
286 views

SQLite3 doesn't have concat_ws, looking for workaround

I'm trying to concatenate some columns and I would like to use space as my output string delimiter. Basically concat_ws would be a perfect fit, but it doesn't exist for SQLite3. I'm inside a ...
1
vote
2answers
1k views

How to Concatenate DateTime to nvarchar field

I have a table with a nvarchar(32) column and I want to update the value in this column with the first 10 bytes of another field on the table which is defined as nvarchar(32) after the 10 bytes I want ...
1
vote
1answer
55 views

Removal of blank lines

I am creating a SSRS Report to produce some address labels. I have a SELECT statement as follows: SELECT DISTINCT AddressLink.intAddressID, Addresses.txtLabelSalutation, ...
6
votes
2answers
4k views

Conditional string concatenation in PostgreSQL

I have a table parcels which currently contains the columns owner_addr1, owner_addr2, owner_addr3. Sometimes, one or both of the latter two fields is empty. I want to combine them into a single new ...
-1
votes
1answer
2k views

Update a table using values from another table

I have two tables with structure Table1 ------ No | Name | IDNo | HouseNoBlock Table2 ------ IDNo | HouseNo | Block I am trying to update the HouseNoBlock Column of first table with value ...
2
votes
1answer
613 views

MySQL “Out of sort memory” error on a simple GROUP_CONCAT query

I have a (what it seems to me) simple query which fails to run on a simple table, the error is: Out of sort memory, consider increasing server sort buffer size These are the SQL statements which I'...
1
vote
3answers
210 views

Array to string sometimes concatenates fewer values

array_to_string(array_agg(array_to_string(array[ highlights,exceptions,inter_note,inter_status::text ,comp_note,comp_status::text,hard_note,hard_status::text] ,'|#|'::...
1
vote
1answer
3k views

Optimizing query. FOR XML PATH or some alternatives?

Is there any way to optimize the FOR XML PATH statement? Or maybe I should use another approach? Current approach is not acceptable at all. It takes minutes. I know view is a really big union and it ...
0
votes
2answers
66 views

Is there any way to concatenate a value in a column with different strings?

As you can see on the column 'Race Position' I have a set of values corresponding to the participants results. 1 being 1st Position and so on. What I wanted was to be able to concat the values and ...
3
votes
1answer
601 views

How do I build a PostgreSQL ORDER BY expression based on a concatenation of columns?

I'm using Postgres 9.5. I want to write an order by expression for a series of concatenated strings, but I'm not sure if that's possible or how to do it. I have cobbled together the below myproject=...
0
votes
1answer
2k views

Loop inside of query in mysql procedure. Is it possible?

I have the following query: INSERT INTO major (key_1, key_2, ... , key_N) VALUES (v_1_1, v_1_2, v_1_3, ... , c_1_N) (v_2_1, v_2_2, v_2_3, ... , c_2_N) ... (v_K_1, v_K_2, v_K_3, ....
0
votes
2answers
863 views

Query with join and concatenation of one joined table's column

I have the following structure: Table R Table RZ (n-m) Table Z ------- ----------------- --------- R1 R1 | Z1 Z1 | "A" R2 R1 | Z2 Z2 | "B" R3 ...
0
votes
1answer
59 views

Concatenating Multiple Columns in TSQL

I have the following data JoinFlag ReferenceType ReferenceValue A CARRIER Sample####### A LEASE_NUMBER 17438 A LEASE_NUMBER 6054 A ...
0
votes
2answers
114 views

Elegant way for concatenation

I am looking for the most elegant solution to prevent the addition of the last/ final separator ';' after the last row. For example the result should be 'Peter,Paul,Jill' instead of 'Peter,...
0
votes
1answer
3k views

SQL server Like pattern match with CONCAT() always fails

I am facing problem in a simple query script for SQL server. Please help The script is CREATE PROCEDURE [dbo].[Search_By_Author_And_Name] ( @Author_name AS [varchar](50) ) AS BEGIN Select B....
1
vote
4answers
11k views

MySQL 5.7 JSON_MERGE combine with GROUP_CONCAT

we have table with JSON column for example simple: {"a": 1} {"b": 2} run JSON_MERGE query select JSON_MERGE('{"a": 1}','{"b": 2}') result correct: {"a": 1, "b": 2} run the GROUP_CONCAT query ...
2
votes
1answer
58 views

How to migrate a huge application to CONCAT_NULL_YIELDS_NULL ON

Finally, none of our customers are using SQL Server 2005 anymore, so we can drop support for it and start using all those awesome "new" SQL Server 2008 features (indexed views, filtered indexes, query ...
20
votes
2answers
671 views

Why does Concatenation operator estimate fewer rows than its inputs?

In the following query plan snippet, it seems obvious that the row estimate for the Concatenation operator should be ~4.3 billion rows, or the sum of the row estimates for its two inputs. However, an ...
6
votes
3answers
43k views

SQL Row concatenation with XML PATH and STUFF giving aggregate sql error

I am trying to query two tables and get results like the following: Section Names shoes AccountName1, AccountName2, AccountName3 books AccountName1 The tables are: CREATE TABLE dbo....
0
votes
2answers
2k views

Concatenate column values [duplicate]

I have a query that uses a couple joins to get a name from another table. It works okay except that I would like to combine "Examiners Name" instead of having multiple duplicates: ID | Name ...
22
votes
2answers
83k views

'CONCAT' is not a recognized built-in function name

A client reported that they were running on SQL Server 2012, and we delivered some test queries for testing prior to a final delivery, however: 'CONCAT' is not a recognized built-in function name. ...
1
vote
0answers
167 views

Mysql trigger with group_concat

I'm trying to create insert and update triggers with SELECT GROUP_CONCAT request on one of the fields; This select query perfectly works, when I trying it in console, but trigger saves only first ...
3
votes
1answer
5k views

Syntax error with concat in trigger near signal statement

Please help me with syntax for MySQL 5.6. For some reason I get the error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version ...
1
vote
2answers
5k views

Concatenate Columns in Stored Procedure [duplicate]

I have a stored procedure which returns a weekly result from input parameters start date and end date. I am getting multiple rows in the result. Requirement: I want to add the results of columns in a ...
11
votes
4answers
33k views

How to exclude NULL values inside CONCAT MySQL?

If I have this - tadd is the Address table: CONCAT(tadd.street_number, ' ', tadd.street_name,', ', tadd.apt_number,', ', tadd.city,', ', tadd....
1
vote
1answer
395 views

convert 1 row as column and concatenate the results to the corresponding column

I have 2 tables table 1 - apps ----------- id | name ----------- 1 | abc ----------- 2 | sdf ----------- 3 | dfg ----------- table 2 - contacts ------------------------ id | cnt_type | ...
1
vote
2answers
1k views

query to concatenate columns if record duplicate

My table has two column that is id and name. I want to do concatenate the columns if the if more than two names are same like: id ...
2
votes
2answers
2k views

Creating a stored procedure and adding date manually to filename

I am new to SQL administration and have been tasked with creating some nightly jobs that send an email with certain details contained within a spreadsheet and so far I have the following: EXEC msdb....
2
votes
3answers
2k views

Problem with mysql group_concat, complex query, not getting required result

I have 5 tables college trade district contact intake Their relationship looks like this I'm having problem with the contact table. In this table, cid and location are the primary key. It can have ...
3
votes
1answer
1k views

Adding two columns results in concatenation instead of addition

I need help using addition. When I do it populates using the concatenate function. I used the following in my access database Total: [ANTI TERROR]+[Records] and instead of returning 1 + 1 = 2 it ...
-4
votes
1answer
8k views

Selecting only some columns from a table

I have a MySQL table that consists of around 200 columns. The name of each column is col_i (i=1 ,2,..200). Suppose I have to select only first 50 columns, how should I proceed? I found about the ...
7
votes
2answers
2k views

What is the most efficient way to concatenate strings in SQL Server?

I have this code: DECLARE @MyTable AS TABLE ( [Month] INT, Salary INT ); INSERT INTO @MyTable VALUES (1,2000), (1,3100); SELECT [Month], Salary FROM @MyTable; Output: I want to concat the ...
1
vote
2answers
5k views

Concatenate date and varchar

I am need to select the date stored in a column transactionDate datatype date and time stored in column transactionTime datatype varchar from a table transactionTable in mysql. My query is like ...
0
votes
2answers
1k views

How can I use 'system pwd' command with MySql CONCAT() function?

How can I use 'system pwd' command with MySql CONCAT() function? I tried select concat('test', system pwd); gives me ERROR 1583 (42000): Incorrect parameters in the call to native function 'concat'...
1
vote
1answer
281 views

CONCAT() between different alphabet echoes out '&' ampersand

I want to concatenate different alphabet strings and get a weird latin encoding with ampersands after the sixth greek character (I want to concatenate greek and english alphabet strings). Lets say I ...
0
votes
2answers
417 views

Concatenate 2-3 table field values in 1 table field in access

I have a project that in Access. The problem is I am a newbie in this application and I really couldn't figure out what to do, I have checked out several ways but am still stuck. I'll be handling a ...
0
votes
0answers
2k views

Insert results of concat

I have a table with 4 columns: ID ORDER_ID QTY VALUE 1 153 1 0 2 476 1 0 3 453 9 1 4 719 2 2 ...
9
votes
1answer
32k views

How to append value of column with double quotes (add quotes around string)

I have a table with a column that is TEXT type. In the column are numeric characters. What I'm trying to achieve is to wrap those characters in double quotes. EXAMPLE: NAME ID QTY Apples ...
-1
votes
1answer
1k views

Stack overflow when parsing a lengthy query

I have a lengthy T-SQL Script. When SQL Server attempts to parse the script, it raises this error: Msg 565, Level 18, State 1, Line 106620 A stack overflow occurred in the server while compiling the ...