I am taking a query from a database, using two tables and am getting the error described in the title of my question. In some cases, the field I need to query by is in table A,
You have to write your where clause in such a way that you can say A.field_from_A or B.field_from_B. You can always pass A.field_from_A.
Although, you don't really want to say
SELECT * FROM A INNER JOIN B ON A.id=B.id where B.id = '1'
.
You would want to say
SELECT * FROM B INNER JOIN A ON B.id=A.id where B.id = '1'
You can get some really slow queries if you try to use a joined table in the where clause. There are times when it's unavoidable, but best practice is to always have your where clause only call from the main table.