HELP - From SQL to Ruby

Hi

How I can execute this query on Ruby?

SELECT *
FROM table_1 T
WHERE T.document_id not in (SELECT distinct documnet_id FROM
binary_files);

Now, I execute without proble the second part of query (SELECT
distinct documnet_id FROM binary_files) in this
method:BinaryFile.find(:first, :select => 'distinct document_id')

I've all crontrollers and all models

Thank you

···

--
I'm using an evaluation license of nemo since 48 days.
You should really try it!
http://www.malcom-mac.com/nemo

Hi

How I can execute this query on Ruby?

SELECT *
FROM table_1 T
WHERE T.document_id not in (SELECT distinct documnet_id FROM
binary_files);

Now, I execute without proble the second part of query (SELECT
distinct documnet_id FROM binary_files) in this
method:BinaryFile.find(:first, :select => 'distinct document_id')

dbh = DBI.open('dbi:mysql:foo','username','password)
dbh.select_all('SELECT * FROM table_1 T WHERE T.document_id not in (SELECT distinct documnet_id FROM binary_files)') do |row|
   # do stuff with rows
end

or, maybe

ksdbh = KSDatabase.new('dbi:mysql:foo','username','password)
doc_ids = ksdbh.select(:BinaryFiles) do |b|
   b.distinct(b.document_id)
end.collect do |d|
   d.document_id
end

data = ksdbh.select(:Table1) {|t| t.document_id.not_in(doc_ids)}

I've all crontrollers and all models

My point is that there are many ways to do what you ask in _Ruby_. I imagine you are actualy wanting to know how to do it in ActiveRecord?

Kirk Haines

···

On Wed, 10 Oct 2007, luciosan wrote:

In article
<Pine.LNX.4.61.0710100922000.11180@server1.enigo.com>khaines@enigo.com
wrote:

My point is that there are many ways to do what you ask in _Ruby_.
I imagine you are actualy wanting to know how to do it in
ActiveRecord?

Thank you for the answare.... yes I'm waiting to know how I can do it
in ActiveRecord.

···

--

I'm using an evaluation license of nemo since 51 days.
You should really try it!
http://www.malcom-mac.com/nemo