Add something to a mysql string field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Add something to a mysql string field

Post by Todd_Z »

Lets say a field has the value White, but I want to add " dog" to it, how do I do that in a query?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

var = &quote;dog&quote;;
mysql_query(&quote;update myTable set myField = concat(myField, '&quote;.$var.&quote;') where id = $myid&quote;)
  or die(mysql_error());
Post Reply