问题
I am developing a web application by python Flask, uses flaskSqlalchemy with PostgreSQL. we have a search functionality where user enter first name, last name, language known. for eg, if the user enters the language as java, it will return a list of empid, with this empid we need to get his full name. my flasksqlalchemy implementation is
langCode = EmpProf().getLancodes(lang)
in EmpProf class
def getLancodes(lang):
return EmpProf.query.distinct(EmpProf.langCod).filter(EmpProf.langKn.ilike('%'+lang+'%')
result = EmplDetails.query.filter(EmplDetails.langCode.in_(langCode),EmplDetails.first_name.ilike('%'+fname+'%'),
EmplDetails.last_name.ilike('%'+lname+'%')
getLancodes
return all column so I extracted the only langCode
but the issue:- results have one row, I am not getting 15 results(row) as we do the same query in query browser.
why the in_ is not returning all rows. what I am missing and
how to get only one column data getLancodes
returns all columns we need to iterate and get required column.
来源:https://stackoverflow.com/questions/62568985/get-all-employees-whose-job-code-in-a-list