0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Rails】whereに配列を指定できる話

Posted at
where(number: [配列])

発行されるSQLは「WHERE IN」の形になる。

 User.where(number: [1, 2])
=>   User Load (0.9ms)  SELECT `users`.* FROM `users` WHERE `users`.`number` IN (1, 2)
[#<User:0x000055eafc265790
  id: "XXXXXXXX",
  number: 1,
  firstname: "コナン",
  lastname: "江戸川",
  email: "conan@gmail.com">,
 #<User:0x000055eafc2656c8
  id: "YYYYYYYYY",
  number: 2,
  firstname: "平次",
  lastname: "服部",
  email: "heiji@gmail.com">]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?