我有一张像下面这样的桌子。
表名users
id Receipt_No type v_amount v_date c_date v_name v_status
7 150325006 SWD 60.00 2015-04-15 2015-04-28 Deepak No
8 150325006 GOODS 1195.00 2015-04-15 2015-04-28 Deepak No
9 150325006 BURNING 290.00 2015-04-15 2015-04-28 Deep No
10 150325006 BURNING 290.00 2015-04-15 2015-04-15 Deep No我只知道v_catagory和v_name列value.Suppose,我有v_catagory="Deep" and v_name="BURNING"信息,我需要所有行值,其v_name ="Deep" and v_catagory="BURNING"和最终显示表中的所有必需值,这意味着id no-9.10应该在table.Please中显示帮助我。
发布于 2015-04-30 05:06:45
您可以尝试使用where方法(假设您的模型是User)。
在你的*_controller.rb里
@result = User.where(type: 'BURNING', v_name: 'Deep')在你看来:
<table>
<% @result.each do |r| %>
<tr>
<th class="text-center"><%= check_box_tag :check_value, 1, :id => "checkbox1-1" %></th>
<td class="text-center"><%= r.id %></td>
</tr>
<% end %>
</table>原始sql:
select *
from users
where type = 'BURNING' and v_name = 'Deep'https://stackoverflow.com/questions/29959383
复制相似问题