Wood Chipper
Wood Chipper

Reputation: 5

PostgreSQL Query tuning up

I am looking to tune up my query.

SELECT student_id,net_id
FROM nstudent
WHERE status_id=3
INNER JOIN ndepart using (net_id)
WHERE NOT deleted;

The above query shows the result but i also want to get the depart_name which is ndepart table, but i cannot figure out how would i do it (probably in descending order)?

Types

FK/PK's

Thank you

Upvotes: 0

Views: 67

Answers (1)

Jonysuise
Jonysuise

Reputation: 1830

SELECT S.student_id, S.net_id, D.depart_name
FROM nstudent S
INNER JOIN ndepart D ON S.net_id = D.net_id 
WHERE s.status_id = 3
AND NOT d.deleted;

Upvotes: 1

Related Questions