I'm trying to do an update that requires table joins but I can't find
any examples of updates beyond simple attribute value assignments.  I
have a select statement like this:

SELECT title, state, name FROM posts, zips, states WHERE posts.zip_id =
zips.id AND states.abbreviation = zips.state;


The posts have a zip but not a state name yet.  So I want to use an
update like this:

UPDATE posts, zips, states SET posts.state_id = state.id WHERE
posts.zip_id = zips.id AND states.abbreviation = zips.state;


I want to do this within a migration.  I can't find any examples of how
a migration like this should be handled.  Does anyone know how to do
this, or where I can find more complex updates than simple attribute
value assignments?

Thanks,
David
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to