Re: Query ID Values

2018-05-15 Thread Adrian Klaver
On 05/14/2018 10:04 PM, Ian Zimmerman wrote: On 2018-05-14 21:12, Adrian Klaver wrote: Because you are doing fetchall(). That is going to fetch a list of row tuples. Either iterate over that list or iterate over the cursor: for row in cur_p: print(row) For more info see:

Re: Query ID Values

2018-05-14 Thread David G. Johnston
n department_id coz I don't know how to >>> access the 3 department IDs in this query. >>>cur_p.execute(""" SELECT id from st_profile where >>> name='$[course]' and department_id=?? """) >>>x = cur

Re: Query ID Values

2018-05-14 Thread tango ward
Fixed the case statement SELECT id FROM education_program WHERE name = CASE %s WHEN 'SENIOR HIGH SCHOOL GAS' THEN 'General Academic Strand' WHEN 'SENIOR HIGH

Re: Query ID Values

2018-05-14 Thread tango ward
I thing its this: " Note cursor objects are iterable, so, instead of calling explicitly fetchone() in a loop, the object itself can be used: >>> cur.execute("SELECT * FROM test;")>>>

Re: Query ID Values

2018-05-14 Thread Ian Zimmerman
On 2018-05-14 21:12, Adrian Klaver wrote: > Because you are doing fetchall(). That is going to fetch a list of row > tuples. Either iterate over that list or iterate over the cursor: > > for row in cur_p: > print(row) > > For more info see: > http://initd.org/psycopg/docs/cursor.html

Re: Query ID Values

2018-05-14 Thread tango ward
e it, I will get "None" >>print x >> >> >> >> Sorry for asking questions a lot, we don't have DBA at the moment. >> >> >> Thanks, >> J >> >> >> On Tue, May 15, 2018 at 9:57 AM, melvin6925 <melvi

Re: Query ID Values

2018-05-14 Thread tango ward
e could suggest a reasonable query. > > > > Sent via the Samsung Galaxy S® 6, an AT 4G LTE smartphone > > Original message > From: tango ward <tangowar...@gmail.com> > Date: 5/14/18 21:08 (GMT-05:00) > To: "pgsql-generallists.postgresql.org" <p

Re: Query ID Values

2018-05-14 Thread David G. Johnston
On Monday, May 14, 2018, tango ward wrote: > > May I ask an advice on how to approach this? > I can't make heads nor tails of your description...but there isn't IF in SQL. But you may get some mileage out of simple joins. David J.

Query ID Values

2018-05-14 Thread tango ward
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