Wednesday, August 28, 2013

Re: django 2 tables one query?



On Tue, Aug 27, 2013 at 11:16 PM, piasek piasek <piasekps@gmail.com> wrote:
Hi 

I was wondering is it possible to get information about two tables in one query?
I have two models 
Team (id, name, active, country) and Player (id, first_name, second_name, active, team)
where Player.team = ForeignKey(Team)
Of course one team may have several players and one player have one team.

Is it possible to get only one, random, player of each team?
for db i use mysql

best regards
slawek

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Sithu Lloyd Dube

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment