sql - 在 SQL 中,如何选择已修改的列?

标签 sql ruby sqlite sequel

我正在尝试使用 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/

相关文章:

MySQL 将重复行计为一个

c# - 传递 C# 变量并将其用作 SQL 语句查询中的列值

html - 适用于 HTML 和文本的回车符

ruby - Ruby 中的命名参数不起作用?

bash - 避免在 bash 中重复设置变量

c# - 如何将时间戳值参数从 C# 传递到 SQL

ruby-on-rails - 带有 Zeus 的 RSpec 3.1,我应该在 spec_helper 中要求 'rspec/rails' 吗?

ruby-on-rails - ruby rails : Accept nested attributes for parent rather than child records?

ios4 - sqlite中的递归外键

c# - Mono 在 Linux 上找不到 System.Data.dll