I am trying to write a simple sql query to return columns if student_id is matched and if another column is true as following:
student_info_query = """
select student_age from students sd
inner join registers rv on sd.id = rv.student_id
where rv.is_paid is true and rv.is_accepted is true
where sd.id = {}
where sd.class_id = {}
"""
query_df = db_connection.query(student_info_query.format(std_id, cls_id))
but I keep receiving error "psycopg2.errors.SyntaxError: syntax error at or near "where" LINE 5 where sd.id = 182"
I also tried with rv.is_accepted = true
and rv.is_accepted = TRUE
, but still same error
Not sure where the error is comming from.
any ideas