This topic is locked
[SOLVED]

 Adding existing records to a new field.

7/14/2011 12:31:08 PM
PHPRunner General questions
Z
zeth385 author

Hey guys!
I have a form with several fields that include Dates, and text fields. It used to work that way since the DB release... they have captured a bunch of info there, but now, my new Boss wants to get rid of those many fields, and just use one single Text-Area-field instead. This is kinda complicated, because those fields already have info... I am wondering if there's a way to "import" the existing data into the new Text-Area-Field... I was thinking something like CONCATENATE, but I'm not pretty sure this is the way it has to be done.
Thanks in advance.
I'm using PHPRunner 5.3 Build 6843.

C
cgphp 7/14/2011

You can create a new field (text type) in your table and run a query like this:



UPDATE your_tabel_name SET new_text_field_name = CONCAT("FIELD 1:",field_name_1,"FIELD 2:",field_name_2,"FIELD 3:",field_name3,...,...,...)


If you are using MSSQLserver the operator for the concatenation is +

Z
zeth385 author 7/14/2011



You can create a new field (text type) in your table and run a query like this:



UPDATE your_tabel_name SET new_text_field_name = CONCAT("FIELD 1:",field_name_1,"FIELD 2:",field_name_2,"FIELD 3:",field_name3,...,...,...)


If you are using MSSQLserver the operator for the concatenation is +


Thanks! I'll give it a try, and I'll post the results

Z
zeth385 author 7/14/2011

It works like a charm!!!!! Thank you so much!!

... just a last question: How do I separate records from eachother... because when I concatenate, i get something like this: AAABBBCCC, and I need to have something like: AAA, BBB, CCC.... Again... THANKS!!

Z
zeth385 author 7/14/2011

Nevermind, I just used

CONCAT_WS(',',Field_1,Field_2,Field_3)

and everyhing is perfect now... Thank you so much.