Forum: Rails Germany Frage zu Sub-Select

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Guido P. (Guest)
on 2008-10-10 17:21
(Received via mailing list)
Hallo zusammen,

wie baue ich diese SQL-Abfrage in Rails?

Select * from USERS WHERE id NOT IN (SELECT user_id FROM PLAYERS)

Es besteht eine 1 zu 1 Beziehung zwischen User und Player.

class User
has_one :player

class Player
belongs_to :user

Danke und Gruß
Guido
Michael S. (Guest)
on 2008-10-10 18:38
(Received via mailing list)
On Friday 10 October 2008, Guido P. wrote:
> Hallo zusammen,
>
> wie baue ich diese SQL-Abfrage in Rails?
>
> Select * from USERS WHERE id NOT IN (SELECT user_id FROM PLAYERS)
>
> Es besteht eine 1 zu 1 Beziehung zwischen User und Player.
>
> class User
> has_one :player

User.find(:all, :include => :player,
  :conditions => "players.user_id IS NULL")

Michael

--
Michael S.
mailto:removed_email_address@domain.invalid
http://www.schuerig.de/michael/
Guido P. (Guest)
on 2008-10-11 14:55
(Received via mailing list)
Vielen Dank Michael

Guido

Zitat von Michael S. <removed_email_address@domain.invalid>:
This topic is locked and can not be replied to.