我正在尝试使用 Ruby 中的 SQL 来执行此操作:
SELECT number*2 FROM dictionary;
我可以使用 .select(:number)
来“按原样”获取数字列,但我不知道如何返回修改过的列。我试过了(这显然不起作用):
current_table.select(:number*2)
最佳答案
尝试其中任何一个
@newnumber = number.find(:all, :conditions => ["id = ?", @dictionary.id], :select => "number * 2 as newnumber")
@newnumber = number.all(:conditions=>"id='#{@dictionary.id}'",:select=>"number * 2 as newnumber")
关于sql - 在 SQL 中,如何选择已修改的列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30523913/