Internet Marketing Forum

Internet Marketing Forum


For Webmasters and Entrepreneurs
|
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 21, 2012, 02:54:56 PM

Login with username, password and session length

I studied the lives of great men and famous women, and I found that the men and women who got to the top were those who did the jobs they had in hand, with everything they had of energy and enthusiasm.


- Henry Truman

|-   Internet Marketing Forum > Online Business Discussions > Website Design and Maintenance > Database
+  

MySql - Add to text field in update statement

0 Members and 2 Guests are viewing this topic.
Pages: [1] Reply to Thread
Author Topic: MySql - Add to text field in update statement  (Read 2356 times)
OfflineGaryGyjax
Junior Member
GaryGyjax is on a distinguished road
Joined: Oct 2007
Posts: 55


Avatar of GaryGyjax

View GaryGyjax\s ProfileWWW
Gender: MaleGemini United States
notepad Dec 01, 2007, 01:21:26 PM #1
I want to know if this syntax is correct before I try anything. I have a field with info in it all ready and I want to add a string to every entree. Is this correct syntax. if not what is. I couldn't find it in the docs.

update table set field = field + 'this is the string';


anyone??

OfflineBrunoBertoli
Beginner
BrunoBertoli is on a distinguished road
Joined: Oct 2007
Posts: 33


anonymous avatar

View BrunoBertoli\s Profile
Italy
notepad Dec 01, 2007, 04:58:35 PM #2
I think you must use a WHERE clause in your query such as

update table set field = field + 'this is the string' WHERE field=value;
OfflineGaryGyjax
Junior Member
GaryGyjax is on a distinguished road
Joined: Oct 2007
Posts: 55


Avatar of GaryGyjax

View GaryGyjax\s ProfileWWW
Gender: MaleGemini United States
notepad Dec 01, 2007, 05:12:43 PM #3
thanks for the reply but I'm trying to update all records in my database that's why there is no WHERE in my statement.

OfflineCode4Gold
Administrator
Code4Gold is a jewel in the roughCode4Gold is a jewel in the roughCode4Gold is a jewel in the roughCode4Gold is a jewel in the rough
Joined: Jan 2006
Posts: 6215


Avatar of Code4Gold

Administrator

View Code4Gold\s ProfileWWW
Gender: MaleGemini United States
notepad Dec 02, 2007, 03:09:29 AM #4
To concatenate a string in MySQL, you need to use the concat function....

update table set field = concat(field, 'this is the string')

The function is "overloaded" so you can concat as many values as you want to like this...

update table set field = concat(field, 'this is the string', 'string2', 'string3', string4')



Latest Blog Post : 8 Tips for Creating a Marketing Buzz

Summer Savings! $7.49 .com domains at GoDaddy.com!
Pages: [1] Reply to Thread


Code4Gold Internet Marketing Forum © 2006-2011 Resdaz Media LLC - All Rights Reserved
Forum Software Powered by SMF - © 2001-2008, Lewis Media. All Rights Reserved.