Hi,
I have a table with the foll. structure :
CAID(int, primary,autoincrement)
AID (int)
CID(int)
Street, Zip, Phone (all varchar)
Now, each CID (company name) can have multiple AID( caddress location). And each AID can be linked to multiple CIDs.
So Company A can have an office in Location A and Location B.
Company B which is a subsidiary of Company A can also have offices in Location A and Location B ie they can share the same premises.
Now the table unfortunately has duplicate records so there will be 2-3 entries of Company A with Location A as an address location etc.
I tried to list only unique records such as:
Company A Location A Street Zip Phone
Company A Location B " " "
Company B Location A " " "
Company B Location B " " "
But the code below gives me CID and AID but not the Street, Zip and Phone data - those columns remain blank.
If i use
$sqla = "SELECT DISTINCT * FROM `Custaddress` ";
only, it lists all the data including the duplicates.
Why is this please ? Any suggestions on how i could change it ?
$sqla = "SELECT DISTINCT `AID`, `CID` FROM `Custaddress` ";
$resulta = mysql_query($sqla) or die (mysql_error ());
do {
printf("<tr>
<td height=30 width=269 bordercolor=#99CCFF><font size=2 face=Tahoma color=#E9CF61><b>%s</td>
AND SO ON....
</tr>",
$myrowa["CAID"],
$myrowa["AID"],
$myrowa["CID"],
$myrowa["Street"],
$myrowa["Zip"],
$myrowa["Phone);
} while ($myrowa = mysql_fetch_array($resulta));