How do you copy a fileds content to newly added field?

Hi All,

I've just finished extracting and saving all the info from my database
and I need to copy the contents from "description" field to the newly
created fields "meta_description" and "meta_keywords" How do you do
this? I don't want my existing data to get messed up. Any help would be
appreciated. Thanks.

I've successfully added the new meta description and keywords using
migrations
<code><pre>
$ ./script/generate migration
remove_description_and_keyword_from_content description:text
keyword:text
      exists db/migrate
      create
db/migrate/003_remove_description_and_keyword_from_content.rb
</pre></code>

*and here's my database schema*
<pre><code>
ActiveRecord::Schema.define(:version => 2) do

  create_table "contents", :force => true do |t|
    t.string "title"
    t.string "description" #<--- How do you copy all data from this
field
    t.text "detail"
    t.string "image"
    t.string "product"
    t.string "link"
    t.float "price"
    t.string "other"
    t.string "target"
    t.float "cost"
    t.string "shipping"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.text "meta_description" #<--- to here and
    t.text "meta_keyword" #<--- Here
  end

end
</code></pre>

- Erwin Quita

update table contents set meta_description = description, meta_keyword
= description;

back up your database first before doing any of this stuff of course.

Mike

Hi Mike

is this a rake task? I tried it and it gave me an error
rake aborted!
Don't know how to build task 'update'

update table contents set meta_description = description, meta_keyword
= description;

Thanks for the quick reply

Mike,

I'm sorry forgot that it's a mysql statement, I tried it on mysql but
gave me this error

UPDATE table contents SET meta_description = description,

meta_keyword = description;
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'table contents SET meta_description = description,
meta_keyword = description' at line 1

How do you properly construct it. Thanks again.

Erwin Quita wrote:

> UPDATE table contents SET meta_description = description,
meta_keyword = description;
ERROR 1064 (42000): You have an error in your SQL syntax; check the

Just: UPDATE contents SET ...

Mark

Thank you so much! Indeed a success! Thanks again!

update contents set meta_description = description, meta_keyword

= description;
Query OK, 989 rows affected (0.29 sec)
Rows matched: 989 Changed: 989 Warnings: 0

Mark Bush wrote:

oops.. thanks Mark, it was late when I posted that!

Mike