Ruby on Rails Monday, December 22, 2014

hi

i have such a model and im not sure how to get the data out:

Task:
- project_id
- name
- timestamp
- value (progress)


now, an insert always insert multiple rows at the same time, but name has different values and so does 'value'



i need a query which gets all tasks for one or more projects, but only the last group of names + values in terms of the timestamp (the most recent group)

im tryin in mysql, aka:
select * from tasks where project == 123 and timestamp = (select max timestamp from tasks where project = 123)

not sure how to get all projects...and in rails


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMdPG_0myjxVi%2B33Ze_-mz%3DbrDstSMQrQAf8f-_dVJ4guw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment