setting value for all records
setting value for all records
am 15.11.2006 14:07:10 von dave
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
Re: setting value for all records
am 15.11.2006 14:39:24 von zac.carey
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()
Re: setting value for all records
am 15.11.2006 17:21:55 von dave
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" wrote in message
news:1163597964.627936.107620@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()
>
Re: setting value for all records
am 24.11.2006 02:00:34 von Michael Austin
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" wrote in message
> news:1163597964.627936.107620@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