<?
$strSQL = "SELECT DISTINCT(detail.ThaiName),detail.*,tel.* FROM detail LEFT JOIN tel ON detail.id_detail=tel.id_detail WHERE detail.Enable='T' AND detail.IsActive='T' ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo $strSQL;
while($objResult = mssql_fetch_array($objQuery))
{
echo "<br>";
echo $objResult["ThaiName"].$objResult["tel"];
}
?>
<br /><br />
<?
$strSQL = "SELECT DISTINCT(detail.ThaiName),detail.*,tel.* FROM detail RIGHT JOIN tel ON detail.id_detail=tel.id_detail WHERE detail.Enable='T' AND detail.IsActive='T'";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo $strSQL;
while($objResult = mssql_fetch_array($objQuery))
{
echo "<br>";
echo $objResult["ThaiName"].$objResult["tel"];
}
?>
<br /><br />
<?
$strSQL = "SELECT DISTINCT(detail.ThaiName),detail.*,tel.* FROM detail INNER JOIN tel ON detail.id_detail=tel.id_detail WHERE detail.Enable='T' AND detail.IsActive='T'";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo $strSQL;
while($objResult = mssql_fetch_array($objQuery))
{
echo "<br>";
echo $objResult["ThaiName"].$objResult["tel"];
}
?>
SELECT valueC
FROM C
INNER JOIN
(
SELECT DISTINCT lookupC
FROM B INNER JOIN
(
SELECT DISTINCT lookupB
FROM A
)
A2 ON B.id = A2.lookupB
)
B2 ON C.id = B2.lookupC
SELECT DISTINCT(detail.ThaiName),detail.ThaiName,tel.tel FROM detail LEFT JOIN tel ON detail.id_detail=tel.id_detail WHERE detail.Enable='T' AND detail.IsActive='T'
SELECT DISTINCT(detail.ThaiName),detail.ThaiName,tel.tel FROM detail RIGHT JOIN tel ON detail.id_detail=tel.id_detail WHERE detail.Enable='T' AND detail.IsActive='T'
SELECT DISTINCT(detail.ThaiName),detail.ThaiName,tel.tel FROM detail INNER JOIN tel ON detail.id_detail=tel.id_detail WHERE detail.Enable='T' AND detail.IsActive='T'
SELECT detail.ThaiName,tel.tel FROM detail INNER JOIN tel ON detail.id_detail=tel.id_detail WHERE detail.Enable='T' AND detail.IsActive='T' GROUP BY detail.ThaiName, tel.tel