Query ID Values - Mailing list pgsql-general

From tango ward
Subject Query ID Values
Date
Msg-id CAA6wQLLiPJkHBpH6SKi5QEymC3n-FUKMXm03Msf9Oy4Ut6dK2g@mail.gmail.com
Whole thread Raw
Responses Re: Query ID Values  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general

Good Day,

I need to run an SQL query and get a program_id and department_id of a specific course for each student. I am thinking of running an IF condition to check if the course name is in program and get it's ID but I don't know yet where to use the IF condition in the query.

sample code:

for row in cur_t:
     course = row['course']


     cur_p.execute("""SELECT id from program where name='$[course]']
                               WHERE department_id=?? """)


Problem is I have 3 department IDs ( Senior High, Vocational, Undergraduate ) and each ID have multiple programs/courses. Each program/course is connected to the deparment table via department_id.

May I ask an advice on how to approach this?


Thanks,
J

pgsql-general by date:

Previous
From: Dale Seaburg
Date:
Subject: Re: Strange error in Windows 10 Pro
Next
From: "David G. Johnston"
Date:
Subject: Re: Query ID Values