【问题标题】:In SQL, how can I select a modified column?在 SQL 中,如何选择已修改的列?
【发布时间】:2015-08-11 23:39:24
【问题描述】:

我正在尝试在 Ruby 中使用 SQL 来做到这一点:

SELECT number*2 FROM dictionary;

我可以使用.select(:number) 来“按原样”获取数字列,但我不知道如何修改它们。我试过这个(显然没有用):

current_table.select(:number*2)

【问题讨论】:

标签: sql ruby sqlite sequel


【解决方案1】:

试试这些

@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")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-11
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    • 1970-01-01
    • 2012-06-23
    相关资源
    最近更新 更多