Reputation: 2109
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?
Upvotes: 1
Views: 142
Reputation: 79979
The keyword count
is a reserved word, so you have to escape it with `` like:
... and `count` IN (SELECT Max( `count` ) FROM domainurls ...
Upvotes: 1
Reputation: 15593
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.
Upvotes: 1