How do I append a character to the end of a field?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

How do I append a character to the end of a field?

Post by simonmlewis »

I need to put a slash on the end of all rows for a particular set.

ie. Add / where type = "subcategory".
How do I do that?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do I append a character to the end of a field?

Post by Celauran »

CONCAT

Code: Select all

UPDATE table_name
SET field_name = CONCAT(field_name, '/')
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I append a character to the end of a field?

Post by simonmlewis »

That's it - thanks.
How do I query for various characters in a string. ie. , + *...etc.?

Code: Select all

if (strpos($title, '-') !== false) 
  {
    $invalidtitle = "yes";
  }
I Want to find them all and stop them being added to a field when the page turns over.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do I append a character to the end of a field?

Post by Celauran »

Post Reply