get all employees whose job code in a list

独自空忆成欢 提交于 2020-06-29 03:59:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!