How do I use content from one field, to UPDATE to another?

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 use content from one field, to UPDATE to another?

Post by simonmlewis »

Code: Select all

UPDATE categories SET titletag = 'Stone Selection: <title>''
I Want to update a load of fields to show A particular word, followed by the content of the field.

So if "title" field says "Special", I want the above script to update categories to say: Stone Selection: Special.

How do I do this?
Cannot do it with Stone Selection $title. or just entering title because it just puts that in.

I'm doing this in phpmyadmin.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: How do I use content from one field, to UPDATE to anothe

Post by pbs »

try using

UPDATE categories SET titletag = 'Stone Selection: '.$title.' '
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I use content from one field, to UPDATE to anothe

Post by simonmlewis »

In phpmyadmin, that just changed them all to: Stone Selection: '.$title.'
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: How do I use content from one field, to UPDATE to anothe

Post by pbs »

it will not update through phpmyadmin, $title is PHP variable

if you have "title" field then u can do it like this

UPDATE categories SET titletag = CONCAT('Stone Selection: ', title)

may this will help you
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do I use content from one field, to UPDATE to anothe

Post by simonmlewis »

Bingo - that does it in phpmyadmin. Thx
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply