Click here to get back home

setting value for all records

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
setting value for all records Dave 11-15-2006
Posted by Dave on November 15, 2006, 8:07 am
Please log in for more thread options
Hi

How would i go about populating a new column based on an existing column
pluse a bit of text

i.e i have a column fldID which contains numerics 1,2,3,4 etc and i want to
poulate a column fldIMAGE with values 1.jpg, 2.jpg etc.

Could anyone help me with the sql pleae.

Many thanks

Dave



Posted by strawberry on November 15, 2006, 8:39 am
Please log in for more thread options

Dave wrote:

> Hi
>
> How would i go about populating a new column based on an existing column
> pluse a bit of text
>
> i.e i have a column fldID which contains numerics 1,2,3,4 etc and i want to
> poulate a column fldIMAGE with values 1.jpg, 2.jpg etc.
>
> Could anyone help me with the sql pleae.
>
> Many thanks
>
> Dave

Have a look at concat()


Posted by Dave on November 15, 2006, 11:21 am
Please log in for more thread options
That's great, thanks, I've managed to update all of my records, but I can't
seem to set this CONCAT() as the default value. How would I do that?


>
> Dave wrote:
>
>> Hi
>>
>> How would i go about populating a new column based on an existing column
>> pluse a bit of text
>>
>> i.e i have a column fldID which contains numerics 1,2,3,4 etc and i want
>> to
>> poulate a column fldIMAGE with values 1.jpg, 2.jpg etc.
>>
>> Could anyone help me with the sql pleae.
>>
>> Many thanks
>>
>> Dave
>
> Have a look at concat()
>



Posted by Michael Austin on November 23, 2006, 8:00 pm
Please log in for more thread options
Dave wrote:

> That's great, thanks, I've managed to update all of my records, but I can't
> seem to set this CONCAT() as the default value. How would I do that?
>
>
>
>>Dave wrote:
>>
>>
>>>Hi
>>>
>>>How would i go about populating a new column based on an existing column
>>>pluse a bit of text
>>>
>>>i.e i have a column fldID which contains numerics 1,2,3,4 etc and i want
>>>to
>>>poulate a column fldIMAGE with values 1.jpg, 2.jpg etc.
>>>
>>>Could anyone help me with the sql pleae.
>>>
>>>Many thanks
>>>
>>>Dave
>>
>>Have a look at concat()
>>
>
>
>


use a trigger( functionality added after 5.0 or later ) or have it done by the
application storing the data.

see: http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html

CREATE TRIGGER sometriggername BEFORE INSERT ON `sometable`
FOR EACH ROW
BEGIN
SET NEW.fldIMAGE = concat(NEW.fldid,'.jpg');
END
;


--
Michael Austin.
Database Consultant

Similar ThreadsPosted
All Records From Table A - All Records From Table B - Join Alike Records October 3, 2006, 11:24 am
setting database pw November 22, 2005, 3:52 am
C API, setting language, MyISAM August 21, 2005, 10:15 pm
Re-setting mysql as a service September 28, 2005, 8:45 am
setting mySQL parameters via PHPmyadmin November 1, 2006, 8:36 am
MySQL Performance - Option setting February 27, 2007, 2:02 am
Connector/ODBC not saving Port setting August 7, 2005, 4:08 pm
Setting linesize and column size in MySQL 4.1.1? May 22, 2006, 10:30 am
setting a collumn to be unique in existing table October 22, 2006, 12:01 pm
SETting a datetime field based on a text field September 29, 2006, 5:42 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap