code for searching the query in such a way that it should search the keyword from both table1 &2 in which the table 1

I have a database which has 2 tables in table1 there is data of around 5000 rows and in this cid is the primary key and in table2 there are the alternate names of the names which is in table1.

now what I want to do is whenever someone searches a keyword it should go and check both the tables and then display the only when they have the same cid. and the table2 has many entries and though the cid is in repetition.

can someone give me a suitable solution for the same.I really need the help and that too urgent..