Hi ,

I have 2 tables room_types and room

the table structure

class room_types(models.Model):
    room_type_id = models.AutoField(primary_key=True,null=False,blank=False)
    room_type_name =
models.CharField(max_length=100,unique=True,null=False,blank=False)
    room_type_desc = models.TextField(null=True)
    standard_occupancy = models.IntegerField()
    higher_occupancy = models.IntegerField()
    base_price = models.DecimalField(max_digits=8, decimal_places=2)
    higher_price = models.DecimalField(max_digits=8, decimal_places=2)
    status = models.ForeignKey('common.status')


class rooms(models.Model):
    room_no
=models.IntegerField(primary_key=True,null=False,blank=False,unique=True)
    room_desc=models.TextField(null=True)
    room_type=models.ForeignKey('room_types')
    block=models.ForeignKey('blocks')
    floor=models.IntegerField()
    room_status=models.ForeignKey('room_status')


Here room_type_id is pk in room_types and is fk in rooms table

and to display the list of rooms the quesry should be

select r.room_type_id,r.room_no,rt.room_type_name from room_types rt,rooms r
where rt.room_type_id=r.room_type_id

How to give this query in django 

Thanks in advance


-- 
View this message in context: 
http://old.nabble.com/How-to-use-subqueries-in-django-tp26387486p26387486.html
Sent from the django-users mailing list archive at Nabble.com.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.


Reply via email to