two field table: field1, field2, how to add a third one with the auto-generated value replace(field2,'channel','AAAA')?

Started by zxo102 ouyangover 16 years ago2 messagesgeneral
Jump to latest
#1zxo102 ouyang
zxo102@gmail.com

Hi evreyone,
I have a table with two fields

field1 field2
1 1channel
2 2channel
3 3channel

Now I want to add the third one with the value
replace(field2,'channel','AAAA') like

field1 field2 field3
1 1channel replace(field2,'channel','AAAA')
2 2channel replace(field2,'channel','AAAA')
3 3channel replace(field2,'channel','AAAA')

The field3 must be done automatically after a user input data into field1
and field2.

Any ideas? Thanks a lot.

ouyang

#2Scott Marlowe
scott.marlowe@gmail.com
In reply to: zxo102 ouyang (#1)
Re: two field table: field1, field2, how to add a third one with the auto-generated value replace(field2,'channel','AAAA')?

On Sat, Dec 12, 2009 at 7:05 PM, zxo102 ouyang <zxo102@gmail.com> wrote:

Hi evreyone,
   I have a table with two fields

   field1    field2
    1         1channel
    2         2channel
    3         3channel

Now I want to add the third one with the value
replace(field2,'channel','AAAA') like

   field1    field2           field3
    1         1channel    replace(field2,'channel','AAAA')
    2         2channel    replace(field2,'channel','AAAA')
    3         3channel    replace(field2,'channel','AAAA')

The field3 must be done automatically after a user input data into field1
and field2.

Any ideas?   Thanks a lot.

So, where are you headed. Should the third field ALWAYS be field2
with channel replcaed by AAAA? Or could it change after you've set it
at first to that? If it will always be the same as field2 with the
replacement, then creating a simple updatable view with the third row
always computed is a reasonable choice.

If you just want it set on insert or update of field2, but then want
it to be modifiable, then a trigger might be a good answer.