Skip to content

Joining two table and get data from both table based on certain column in django

At first i want to make understand you to be not overactive or over-reactive without giving any solution and not understanding the core content and topics of questions.Here many people available who are expert at overacting and over-reacting by giving minus vote knowing anything.If you do not like this question then ignore it because your minus vote prevent many important questions from getting researched and answered.

However, have two table named ‘transaction’ and ‘member’. I want to join this two table like this :-

$select=$connect->query("SELECT as id, as date, as name,member.address as address FROM transaction,member WHERE ORDER  BY ");

     echo $data['id'];
     echo $data['name'];
     //i echo it for your clearance 

I need Django query from it which i will get same result.

Please don’t give any other questions reference something related to it.I need specific solution from this.



This select_related part will join the two tables (transaction, member) with condition ( ) then order_by(‘id’) will order the output with

query = transaction.objects.select_related('member').order_by('id')

To print ids

print(list(query.values_list('id', flat=True))))

To print list on names

print(list(query.values_list('names', flat=True))))
3 People found this is helpful