1

This is the mysql code written for ruby on rails application

Model.find_by_sql(["SELECT * FROM domainurls WHERE domaindetail_id = ?",@id ,"and count IN (SELECT Max( count ) FROM domainurls WHERE domaindetail_id =?",@id,")"])

It gives me error

"error is: wrong number of arguments (0 for 1)"

Can anybody have idea what's wrong in the code?

1
  • May be you should add a space before "and count in..." Commented Jan 4, 2012 at 10:26

2 Answers 2

1

Here you require data in two query because of IN can search data within an array. Either your query

(SELECT Max( count ) FROM domainurls WHERE domaindetail_id =?",@id,")

will return many column.

So first execute this query and take counts in a array and after that execute second query.

I think you have understood.

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

Comments

1

The keyword count is a reserved word, so you have to escape it with `` like:

... and `count` IN (SELECT Max( `count` ) FROM domainurls ...

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.