$sql=mysql_query("select y.* from y left join x on y.neresi=x.id where x.x1='$_SESSION[id] or x.x2='$bb'"); while ($row=mysql_fetch_assoc($sql)){ }