ok, I have 4 tables which I would like to join...

The first, deals:

HTML Code:
DealsHandsetID  DealsTariffID  Price  Monthsfree  Monthshalf  Cashback  Gift  RetailerID
2nd - handsets:
HTML Code:
HandsetName  Manufacturer  HandsetID  Date  Features  Description
3rd - tariffs:
HTML Code:
TariffID  TariffName  TariffDescription  Anytime  OffPeak  Texts  LineRental  Cost  ContractType
4th - retailers:
HTML Code:
RetailerID  RetailerName  RetailerImage  RetailerCommission
My script below only using the handsets table.. but i would like to join the tables together to show only handsets with deals, and of those deals the ContractType must not equal "pp"

So, I want to do something like:

HTML Code:
Select handsets.*, deals.*, tariffs.*, retailers.* from handsets LEFT JOIN deals ON handsets.HandsetID = deals.DealsHandsetID JOIN LEFT tariffs on tariffs.TariffID = deals.DealsTariffID LEFT JOIN retailers on retailers.RetailerID = deals.RetailerID WHERE tariffs.ContractType != 'pp' GROUP BY handsets.HandsetID
Heres my current code:


$conn = mysql_connect($address, $username, $password);
$rs = mysql_select_db($database, $conn);
$sql="SELECT * FROM handsets WHERE Date >= '803' GROUP BY HandsetName ORDER BY RAND() LIMIT 0, 40";
$rs = mysql_query($sql, $conn);
$j = 0;

while($row = mysql_fetch_array($rs)) { 

$HandsetID = $row[HandsetID];
$Manufacturer = $row[Manufacturer];
$HandsetName = $row[HandsetName];
$Date = $row[Date];
$Features = $row[Features];
$Description = $row[Description];

$ManufacturerClean = str_replace(" ", "-", $Manufacturer);
$ManufacturerClean = strtolower($ManufacturerClean);

$HandsetNameShow = str_replace("$Manufacturer ", "$Manufacturer<br />", $HandsetName);
$HandsetNameClean = str_replace(" ", "-", $HandsetName);
$HandsetNameClean = strtolower($HandsetNameClean);

<div class=\"dealsmake\">
		<a class=\"menusmall\" href=\"/mobiles/$ManufacturerClean/$HandsetID.html\" title=\"$HandsetNameTitle\">
		<img class=\"noborder\" alt=\"$HandsetNameTitle\" src=\"/med$HandsetID.jpg\" height=\"75\" />
		<br /><br />$HandsetNameShow
  if(($j % 4) == 0) echo(""); 
Please helppp!!! thanks!!!