0

How can we write this SQL in Rails3 . tables : node, meta

select n.node_id
from node n
join meta m1 on m1.node_id = n.node_id 
            and m1.code = 'weight' and m1.value = '120'
join meta m2 on m2.node_id = n.node_id
            and m2.code = 'lower' and m2.value = '1'
join meta m3 on m3.node_id = n.node_id
            and m3.code = 'height' and m3.value = ''

Thanks in advance.

1
  • It's better if you explain what you want to do, in english, referring to your rails schema, rather than ask people to reverse engineer sql. Commented Jun 3, 2011 at 10:46

1 Answer 1

1

You can use ActiveRecord::Base#find_by_sql method to get query results. Read more here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.