From: Paul Willis Date: 2007-03-27T06:10:46+09:00 Subject: Re: Ruby/MySQL SELECT results >> hasid = my.query("SELECT id FROM table WHERE title = 'Here is a title'") >> puts hasid >> >> I get a result like... >> >> # >> >> I am expecting just the number in the id field. Any ideas? > > hasid.each do |row| > puts row > end > > Keep in mind, that Ruby/MySQL doesn't "rewind" after using an iterator. > > I've circumvented that by doing the following: > > array = Array.new > hasid.each do |row| > array.push(row) > end I'm having trouble getting my id out of the array to use as a variable in an if/then/else statement I want to get the id (there will only be one in the MySQL database that matches my query, and then do something like... if hasid > 0 then puts "already here with id " +hasid else puts "this will be a new item" end -- Posted via http://www.ruby-forum.com/.