setting value for all records

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
dave [ Mi, 15 November 2006 14:07 ] [ ID #1536594 ]

Re: setting value for all records

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()
zac.carey [ Mi, 15 November 2006 14:39 ] [ ID #1536595 ]

Re: setting value for all records

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?


"strawberry" <zac.carey [at] gmail.com> wrote in message
news:1163597964.627936.107620 [at] m73g2000cwd.googlegroups.com.. .
>
> 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()
>
dave [ Mi, 15 November 2006 17:21 ] [ ID #1536600 ]

Re: setting value for all records

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?
>
>
> "strawberry" <zac.carey [at] gmail.com> wrote in message
> news:1163597964.627936.107620 [at] m73g2000cwd.googlegroups.com.. .
>
>>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
Michael Austin [ Fr, 24 November 2006 02:00 ] [ ID #1546298 ]
Datenbanken » mailing.database.mysql » setting value for all records

Vorheriges Thema: Mysql refusing to start
Nächstes Thema: Mysql or standard sql advanced manual