Can't seem to Compare MySQL Statement

Hello, I am having a problem seeing if a SQL statement worked or not... I know I'm not really doing my SQL statement the proper 'RoR' way, but I don't think that is the problem. My code is supposed to query the database where the displayname = the posted legalname. If no results are returned, then do the same query, but where displayname = the posted othername. The problem is when it evaluates if @compare_bes == nil.... even if it doesn't return results, it won't execute the stuff within the IF statement.

@compare_bes = Bes.connection.select_all("   SELECT *   FROM bes   WHERE   bes.bes_displayname = '#{params[:legalname]}'")

if @compare_bes == nil <--- THIS IS THE PROBLEM @compare_bes = Bes.connection.select_all("   SELECT *   FROM bes   WHERE   bes.bes_displayname = '#{params[:othername]}'")

end

So I am not sure what do use to evaluate if the first query is empty. I tried @compare_bes == '', == "", unless @compare_bes, unless @compare_bes != nil, etc...

Does anybody know how to do this?

Any help is appreciated!

Thanks, - Jeff Miller

Have you tried:

if @compare_bes.empty?

Have you tried:

  @compare_bes.empty?

that worked perfectly! I have to remember that. Thanks!!

No problem!