my input query is
query = "select * from tab1 left join tab2 on tab2.patient_id =tab1.patient_id ,tab3 left join tab4 on tab4.patient_id =tab3.patient_id"
data = model_name.objects.raw(query)
How do you retrieve values from a RawQuerySet
?
my input query is
query = "select * from tab1 left join tab2 on tab2.patient_id =tab1.patient_id ,tab3 left join tab4 on tab4.patient_id =tab3.patient_id"
data = model_name.objects.raw(query)
How do you retrieve values from a RawQuerySet
?
The result obtained by making raw queries using
raw
method ofManager
generates instances similar to instances generated usingget
orfilter
method. To get a field simply doobj_name.attr
.For eg:
For more info, refer to https://docs.djangoproject.com/en/dev/topics/db/sql/