在我想这一点,不知道我这样做正确:获取该COLUMN_ID所有行是ID的数组,然后才能通过ID
User.where("region_id => ?", region_ids).order("id ASC")
region_ids = [1234,234322,234324,2343,....]
此外,将这项工作如果region_ids是空的(不为空,但空)
我看到了一个错误:
check the manual that corresponds to your MySQL server version for the right syntax to use near '=> NULL) ORDER BY id ASC' at line 1:
当我在调试模式下,我输出的region_ids,这是[]。
大部分是正确的,但第一个例子应该是(“region_id in(?)”,region_ids)。 – 2011-04-12 03:25:56
谢谢,如果/当Rails自动执行此操作时,我无法回想起我的头顶。 – Daemin 2011-04-12 03:42:16
如果region_ids是[],它会在查询中显示为NULL吗?它看起来是为我... – Blankman 2011-04-13 01:03:24