How to get a list value of `<class 'flask_sqlalchemy.BaseQuery'>`?

I'm sure this is a simple issue that I'm just missing, but I have this Sheet

which has a query function on the "Helper" sheet that should pull in the corresponding row for the job selected on the "Job Entry" sheet. However, for the second test job ("TEST002"), it is only pulling in the first 14 task names, but all 21 hours. Before I added TEST003, it was only pulling in 8 task names and the 21 hour slots, but I added 14 tasks to TEST003, and now 14 names come in. This is very confusing to me as both TEST001 and TEST003 pull correctly. This is the query I'm using to pull in the appropriate row from the database tab:

=query(Database!1:1000,"select * where A = 'Job' and D = '"&'Job Entry'!K5&"'")

I shared this slimmed down sample sheet just to make it easy to see, because I'm not exactly sure how to word the issue. But just for extra clarity, each job row from the one tab ("Database") has a location, a client name, 4 numbers for job, engine, head, and trans, up to 21 task names and up to 21 corresponding task allocated hours. For the one job that has all 21 tasks, it pulls in everything except for task names 15-20. Notably, there are three jobs in the database at the moment, this one with 21 tasks, TEST003 with 14 tasks, and TEST001 with 8 tasks (not important). Basically, it only brings in as many task names as the job with the second most tasks has.

I hope this is all clear enough for someone to help. Thanks!


Solution 1:

Be carefull with query when you have strings and numbers in the same column ! You need to transform with to_text. Try this

=query(arrayformula(to_text(Database!1:1000)),"select * where Col1 = 'Job' and Col4 = '"&'Job Entry'!K5&"'")

Solution 2:

Here are other possible solutions:

=query( Database!1:1000, "where A = 'Job' and D = '"&'Job Entry'!K5&"'")
=FILTER( Database!1:1000, Database!A1:A1000 = "Job", Database!D1:D1000 = 'Job Entry'!K5)