在我想這一點,不知道我這樣做正確:獲取該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