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: http://initd

Re: Query ID Values

2018-05-14 Thread David G. Johnston
#x27;t know how >>> to do it yet >>># I put ?? in 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='$

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 SCHO

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;")>>> f

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 Whe

Re: Query ID Values

2018-05-14 Thread tango ward
() >># This will print an error since I added department_id >> without value yet but if I remove it, I will get "None" >>print x >> >> >> >> Sorry for asking questions a lot, we don't have DBA at the moment. >> >> >&g

Re: Query ID Values

2018-05-14 Thread Adrian Klaver
Date: 5/14/18 21:08 (GMT-05:00) To: "pgsql-generallists.postgresql.org <http://pgsql-generallists.postgresql.org>" mailto:pgsql-general@lists.postgresql.org>> Subject: Query ID Values Good Day, I need to run an SQL query and get a progr

Re: Query ID Values

2018-05-14 Thread tango ward
> > > Thanks, > J > > > On Tue, May 15, 2018 at 9:57 AM, melvin6925 wrote: > >> Perhaps if you care to provide us with the structure of all tables >> involved, we could suggest a reasonable query. >> >> >> >> Sent via the Samsung Galaxy S® 6, an AT&

Re: Query ID Values

2018-05-14 Thread tango ward
structure of all tables > involved, we could suggest a reasonable query. > > > > Sent via the Samsung Galaxy S® 6, an AT&T 4G LTE smartphone > > Original message ---- > From: tango ward > Date: 5/14/18 21:08 (GMT-05:00) > To: "pgsql-genera

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