relational advance search

Suppose i have three table table1 table2 table3 table2 and 3 have relation with table1 .if i create crud for table1 it will give searching .but how i can search data using table 1 and table 2 attributes in table1 for example

table 1 have user info name ,age,email ect table 2 have interest like cricket,football,coding etc.if i write cricket on text box n click to search it should show that user who have interest in cricket.how i can do it plz help me .i am trying it from last two days but i did not get the solution.




        $searchCriteria = new CDbCriteria(); 

        $searchCriteria->select = "t.title, t3.user_id";

        $searchCriteria->join = "INNER JOIN table3 t3 ON t.id = t3.interest_id WHERE t3.user_id = ".$user_id;

        $data1 = Interest::model()->findAll($searchCriteria);



Having table3 the relations between interests and users, $data1 should have all interests of user with id = $user_id

You can modify the query to get more data from the users by adding another join to the users table

Hope it helps!