Обсуждение: Dashed if I can work this out. Help needed copying substring to another field
Dashed if I can work this out. Help needed copying substring to another field
От
Robert Chalmers
Дата:
Hi, I'm really foxed on this. In a PostgreSQL database table, I have three fields. "category","language","code" "code" is made up of category+language+code-numbers for example: 10CE4578P or 9E457CT So in this case, 10 is the 'category', CE is the 'language', and the rest makes up the code. or So in the 2nd case, 9 is the 'category', E is the 'language', and the rest makes up the code. I have 2758 records with the third field, 'code' filled in already. Thats how it comes. I want to extract the two first parts, and put them into their respective fields. That is, take the '10' and put it into the 'category' field, take the CE and put it into the 'language' field, and leave the 'code' field as it is. It looks like some sort of repetative statement needs to be written so it steps down the entire table, adjusting each record as it goes, but I'm at a loss as how to do it. If I could discover a way to simply extract this info from the 'code' field on the fly, with accuracy, I could probably forget the two fields of category,language and simpy search on the code field, but I can't work it out. Maybe I need to take a break... Does anyone have any ideas? I could really use some help on this one... Thanks Robert -- http://www.chalmers.com.au. Publications From China in 24 different languages. English, French, German, Russian, Arabic, Spanish, Chinese, Burmese, Bengali, Hindi, Indonesian, Italian, Japanese, Korean, Portuguese, Persian, Swahili, Sinhalese, Thai, Tamil, Urdu, Vietnamese. China Books for CIBTC, Beijing.