From: Phillip Gawlowski Date: 2007-03-27T06:43:41+09:00 Subject: Re: Ruby/MySQL SELECT results Paul Willis wrote: > > 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 Try the Mysql::Result#fetch_field_direct method. This should do what you want. At least it did when I played with it in irb. -- Phillip "CynicalRyan" Gawlowski Rule of Open-Source Programming #6: The user is always right unless proven otherwise by the developer.