From: Sharon Rosner Date: 2007-07-22T22:12:39+09:00 Subject: Re: first ruby script mysql data input > ids = [] > res = db.query( "select id from mytable") > while row = res.fetch_row do > ids << row[0] > end > res.free > ids.map! { |i| i.to_i } # do this just in case mysql doesn't return integers > # at this point you have an array of integers, how you get here is up to you > # now, for the ruby chocolate ... > free_ids = (1..ids.max).to_a - ids here's the sequel version: require 'sequel/mysql' DB = Sequel.open('mysql://user@localhost:/mydb') free_ids = (1..ids.max).to_a - DB[:mytable].map(:id) best sharon