如何从一个数据库中的多个表中获取多个值?

i have a serious problem!

I want to use different values from different tables in my database. My tables:

users

user_id | name | email | password | color | created

parents

parent_id | email | password

So, i want to connect these tables with email col. But passwords cols are different.

Here is my code:

        $_SESSION['logged_in2'] = false;
    if( !empty( $data ) ){

        // Trim all the incoming data:
        $trimmed_data = array_map('trim', $data);

        // escape variables for security
        $email = mysqli_real_escape_string( $this->_con,  $trimmed_data['email'] );
        $password = mysqli_real_escape_string( $this->_con,  $trimmed_data['password'] );

        if((!$email) || (!$password) ) {
            throw new Exception( PARENTS_FIELDS_MISSING );
        }
        $password = md5( $password );

        $query = "SELECT parent_id, email FROM parents where email = '$email' and password = '$password' union all SELECT name FROM users ";
        $result = mysqli_query($this->_con, $query);
        $data = mysqli_fetch_assoc($result);
        $count = mysqli_num_rows($result);
        mysqli_close($this->_con);
        if( $count == 1){
            $_SESSION = $data;
            $_SESSION['logged_in2'] = true;
            return true;
        }else{
            throw new Exception( PARENTS_FAIL );
        }
    } else{
        throw new Exception( PARENTS_FIELDS_MISSING );
    }

How can i use these tables in one code? Please help! By the way, the error is this:

mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

Perhaps use a combined query(join) like this :

select a.*, b.* from table users as a join parents as b on a.email = b.email where a.email = "$email" and a.password = "$password"

updated :

SELECT b.user_id, a.email, b.email as parent_email, a.name, a.color, b.password as parent_password FROM users AS a INNER JOIN parents AS b ON a.email = b.email WHERE b.email = '$email' AND b.password  = '$password' ;

$email = mysqli_real_escape_string( $this->_con, $trimmed_data['parent_email'] );
$password = mysqli_real_escape_string( $this->_con, $trimmed_data['parent_password'] );