help requested on multiple table query
I have a database containing three tables that are as follows.
_________________table onechemicals___________
unique ID, Name,generic name ,local name ,formula,photo
____________________________________________________
_________________table Twowith_chem_X_________
unique ID,formula1,formula2.....formula500 (There are 500 columns approx)
____________________________________________________
_________________table Threewith_chem_Y_______
unique ID,formula1,formula2.....formula500 (There are 500 columns approx)
____________________________________________________
Now I want to run a query to bring out results, on bases of search input in the form of text /csv file having only two variables ie input1,input2.
The purpose of the input1 is to search every row/column for match in TABLE TWO (with_chem_X) While input2 is to search every row/column for match in TABLE THREE (with_chem_Y).
only those "unique ID" should come as result where "unique ID" has been found in both the tables.
The output will be unique ID, Name,generic name ,local name ,formula "keyword matched".(in form of csv/txt).
Please guide as to how to formulate query. I have joined the three tables on the basis of "unique ID"