How should django be written in such a way as SQL?

that"s the question. I"ve been looking for it on the Internet for a long time, but I can"t find it.
for example, I want to query
SQL:
select a from atable,btable where atable.id=btable.id

an is the field of atable and b is the field of btable. But I don"t know how to write it with the model class of django. Is there a big god to tell me? be deeply grateful.

Feb.28,2021

your sentence SQL is equivalent to:
select a select b from atable join btable on atable.id=btable.id


find out who's foreign key first, and write

if btable's id is the primary key referencing atable.

from django.db.models import F
Btable.objects.annotate(a=F('atable__a')).values('a', 'b')
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e80c22-45587.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e80c22-45587.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?