473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SQL-Statment that add to strings

Hallo

i have a problem to add to string with a SQL statement.

My Table : Tablename NAMES:

| Name1 | Name2 | Name3 |
John Meyer

I search for a SQL statment that update Name3.

The statemant must add Name1 with Name2 and put the result into Name3
| Name1 | Name2 | Name3 |
John Meyer John Meyer
I have use :

update NAMES SET Name3=Name1+Name2

but it don't works.
Can anybody help me ?

Nov 12 '05 #1
9 15695
Appel wrote:
Hallo

i have a problem to add to string with a SQL statement.

My Table : Tablename NAMES:

| Name1 | Name2 | Name3 |
John Meyer

I search for a SQL statment that update Name3.

The statemant must add Name1 with Name2 and put the result into Name3
| Name1 | Name2 | Name3 |
John Meyer John Meyer
I have use :

update NAMES SET Name3=Name1+Name2

but it don't works.

Can anybody help me ?


Have a look at the manual and read up on the function CONCAT.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #2
>>I have use :

update NAMES SET Name3=Name1+Name2

but it don't works.

Can anybody help me ?

Have a look at the manual and read up on the function CONCAT.

... which also happens to be the SQL standard and should work on all
major RDBMS. Also check out || which is the infix synonym for CONCAT().

Cheers
Serge
Nov 12 '05 #3
Serge Rielau wrote:
I have use :

update NAMES SET Name3=Name1+Name2

but it don't works.

Can anybody help me ?


Have a look at the manual and read up on the function CONCAT.

.. which also happens to be the SQL standard and should work on all
major RDBMS. Also check out || which is the infix synonym for CONCAT().

Cheers
Serge


Of course, if you just concatenate the two names, assuming they're
VARCHAR fields, you're going to to get "JohnMeyer". In other words,
don't forget to put the space in their yourself. If they're CHAR
fields, then each name will be blank padded up to the length of the
field, so you'll likely get "John Meyer "
or something similar.

Just things to keep in mind.
Nov 12 '05 #4
.... and to eliminate the blanks take a look at the "strip"-function.

Regards
Andreas
don't forget to put the space in their yourself. If they're CHAR
fields, then each name will be blank padded up to the length of the
field, so you'll likely get "John Meyer "
or something similar.

Nov 12 '05 #5
"Appel" <ap***@starnet-it.de> wrote in message news:<2u*************@uni-berlin.de>...
Hallo

i have a problem to add to string with a SQL statement.

My Table : Tablename NAMES:

| Name1 | Name2 | Name3 |
John Meyer

I search for a SQL statment that update Name3.

The statemant must add Name1 with Name2 and put the result into Name3
| Name1 | Name2 | Name3 |
John Meyer John Meyer
I have use :

update NAMES SET Name3=Name1+Name2

but it don't works.
Can anybody help me ?

UPDATE names SET name3 = TRIM(name1) || ' ' || TRIM(name2)

But do you really want to store the same information twice?

Its a waste of memory, but even more important is the risk of data
inconsistency. Typically somebody inserts or updates name1 or name2,
but forgets to update name3.

You can perhaps use a view:

CREATE VIEW namesview (name1, name2, name3) AS
SELECT name1, name2, TRIM(name1) || ' ' || TRIM(name2)
FROM names
HTH,
Jarl
Nov 12 '05 #6
Andreas Reiners wrote:
... and to eliminate the blanks take a look at the "strip"-function.


There is no such function in DB2 UDB. You should rather use the RTRIM,
LTRIM, or REPLACE functions.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #7
Knut Stolze <st****@de.ibm.com> wrote in news:cl**********@fsuj29.rz.uni-
jena.de:
Andreas Reiners wrote:
... and to eliminate the blanks take a look at the "strip"-function.


There is no such function in DB2 UDB. You should rather use the RTRIM,
LTRIM, or REPLACE functions.


Really?

f.e.: http://publib.boulder.ibm.com/cgi-bi...nsqj10/3.2.93?
DT=20040216135741

Regards
Andreas
Nov 12 '05 #8
Andreas Reiners wrote:
Knut Stolze <st****@de.ibm.com> wrote in news:cl**********@fsuj29.rz.uni-
jena.de:
Andreas Reiners wrote:
... and to eliminate the blanks take a look at the "strip"-function.


There is no such function in DB2 UDB. You should rather use the RTRIM,
LTRIM, or REPLACE functions.


Really?

f.e.: http://publib.boulder.ibm.com/cgi-bi...nsqj10/3.2.93?
DT=20040216135741


Yes, really - at least if you are on DB2 UDB for Linux, Unix, and Windows.
Your link refers to DB2 for z/OS.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #9
On Thu, 28 Oct 2004 08:13:28 -0400, Serge Rielau wrote:
Have a look at the manual and read up on the function CONCAT.

.. which also happens to be the SQL standard and should work on all
major RDBMS. Also check out || which is the infix synonym for CONCAT().


CONCAT(...) is not specified in the SQL standard, only the ||
concatenation operator. CONCAT isn't even a reserved word.

--
Greetings from Troels Arvin, Copenhagen, Denmark

Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: cooldv | last post by:
i am running a website on Windows 2000 server with ASP 3 webpages and Access 2000 database. (with a hosting company) traffic is slow at this time but expect to grow. lately i have been reading...
2
by: Peter | last post by:
I run most of my SQL scripts via kornshell on AIX. I use the "here-document" to run some of the smaller ones. Example: #!/bin/ksh # Analyze the table. sqlplus...
10
by: Dagwood | last post by:
Good morning: At least it's morning where I am. :) I have a rather newbie question I'm afraid. I have VisualStudio.NET, and have installed it along with SQL server. However I can't seem to...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
4
by: coosa | last post by:
Hi, I was installing SQL Server on my machine and during installation my PC freezed. It happens frequently on my machine. So i tried after restarting to install it again and since then i always...
1
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
6
by: Fuzzydave | last post by:
I am back developing futher our Python/CGI based web application run by a Postgres DB and as per usual I am having some issues. It Involves a lot of Legacy code. All the actual SQL Querys are...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
5
by: dbrother | last post by:
Access 2003 Win XP Pro SP3 Using SQL /ADO Recordsets in a Do Loop Hello, I'm using a random number generator based on an integer input from a user from a form that will get X number of random...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.