当使用mysql从PHP中的两个表进行搜索时,如何在文本字段中搜索相关记录

I have two tables One is registration and the other is user table: I want to search records from both the tables, i can search the record from one table by the step given below but did not know at the same time some text fiels are there in my form which should match with the records in the database i.e. name and address are comming from the other tables.

<?

  $gender=$_POST['GENDER'];
  $age=$_POST['AGE'];
  $Religion=$_POST['RELIGION'];

  $name=$_POST['NAME'];
  $address=$_POST['ADDRESS'];

 $sql = mysql_query("select * from registration where `religion` LIKE '%".$Religion."%' AND `age` LIKE '%".$age."%' AND `gender` LIKE '%".$gender."%'") or die(mysql_error());

  while($row=mysql_fetch_array($sql)){
 ---
 --
 }

My Table Description is as follows:

Registration Table:
Userid
Gender
Age
Religion

User Table:
uid
name
address

Try using UNION -

$sql = "(SELECT * FROM registration WHERE 
         `religion` LIKE '%".$Religion."%' AND
         `age` LIKE '%".$age."%' AND 
         `gender` LIKE '%".$gender."%')  UNION

        (SELECT * FROM user WHERE 
         `name` LIKE '%".$name."%' AND 
         `address` LIKE '%".$address."%')";

ADVICE: Avoid using mysql_* functions since it is deprecated. Learn mysqli or PDO