0

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

  • student_id,net_id are bigint.
  • depart_name is character
  • status_id is integer.

FK/PK's

  • net_id is primary key for ndepart
  • foreign key in nstudent and student_id is primary key for nstudent.

Thank you

3
  • Do not create multiple copies of same question. The previous question had comments about the improvement you needed to do to get an answer. Commented Oct 17, 2013 at 13:44
  • possible duplicate of Multiple PostgresSQL queries Commented Oct 17, 2013 at 13:46
  • wiki.postgresql.org/wiki/SlowQueryQuestions Commented May 20, 2014 at 8:06

1 Answer 1

1
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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.