|
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
|