The query below works fine as long as the searchphrase is found in table d (WYISORG)
however,
if it is found in table d1 (WYISCONTACT)
it extracts ALL the records from WYISORG, not just those that match.
$sql = "SELECT DISTINCT d.* FROM WYISORG AS d, WYISCONTACT as d1 ";
$sql = $sql."WHERE ";
$sql = $sql."(d.ORGANIZATIONNAME LIKE '%$searchphrase%')";
$sql = $sql." OR (d.BRIEF LIKE '%$searchphrase%')";
$sql = $sql." OR (d1.SURNAME LIKE '%$searchphrase%')";
$sql = $sql."GROUP BY ORGID";
$sql = $sql." ORDER BY d.ORGANIZATIONNAME";
What am I doing wrong?
If I join the tables together with an extra where clause
AND (d.ORGID) = (d1.ORGID)
then it won't extract any records that don't also match d1 (WYISCONTACT) and what I want is an OR query
Help!
How do I do an outer join?
or
How do I create a temporary table?
Regards
Elizabeth
however,
if it is found in table d1 (WYISCONTACT)
it extracts ALL the records from WYISORG, not just those that match.
$sql = "SELECT DISTINCT d.* FROM WYISORG AS d, WYISCONTACT as d1 ";
$sql = $sql."WHERE ";
$sql = $sql."(d.ORGANIZATIONNAME LIKE '%$searchphrase%')";
$sql = $sql." OR (d.BRIEF LIKE '%$searchphrase%')";
$sql = $sql." OR (d1.SURNAME LIKE '%$searchphrase%')";
$sql = $sql."GROUP BY ORGID";
$sql = $sql." ORDER BY d.ORGANIZATIONNAME";
What am I doing wrong?
If I join the tables together with an extra where clause
AND (d.ORGID) = (d1.ORGID)
then it won't extract any records that don't also match d1 (WYISCONTACT) and what I want is an OR query
Help!
How do I do an outer join?
or
How do I create a temporary table?
Regards
Elizabeth