例如:
A(member,product,other)
B(member,product,price)A表记录:会员甲,20ml装飘柔洗发水,其他信息
会员甲,40ml装飘柔洗发水,其他信息会员乙,20ml装飘柔洗发水,其他信息
会员乙,40ml装飘柔洗发水,其他信息B表记录:
,20ml装飘柔洗发水,20.00
,40ml装飘柔洗发水,40.00
甲 ,20ml装飘柔洗发水,5.00那么希望查出来的最后结果是:会员甲,20ml装飘柔洗发水,其他信息, 5.00
会员甲,40ml装飘柔洗发水,其他信息,40.00
会员乙,20ml装飘柔洗发水,其他信息,20.00
会员乙,40ml装飘柔洗发水,其他信息,40.00
THANKS!
A(member,product,other)
B(member,product,price)A表记录:会员甲,20ml装飘柔洗发水,其他信息
会员甲,40ml装飘柔洗发水,其他信息会员乙,20ml装飘柔洗发水,其他信息
会员乙,40ml装飘柔洗发水,其他信息B表记录:
,20ml装飘柔洗发水,20.00
,40ml装飘柔洗发水,40.00
甲 ,20ml装飘柔洗发水,5.00那么希望查出来的最后结果是:会员甲,20ml装飘柔洗发水,其他信息, 5.00
会员甲,40ml装飘柔洗发水,其他信息,40.00
会员乙,20ml装飘柔洗发水,其他信息,20.00
会员乙,40ml装飘柔洗发水,其他信息,40.00
THANKS!
$sql="select A.*,B.price from A,B where A.member=B.member and A.product=B.product;";
$result=mysql_query($sql);
echo $sql."<br/>".$result."<br/>";
$tem="0";
while ($rs=mysql_fetch_object($result))
{
$tem=$tem.",".$rs->id;
echo $rs->id." ".$rs->member." ".$rs->product." ".$rs->other." ".$rs->price."<br/>";
}$sql="select A.*,B.price from A,B where B.member='' and B.product=A.product and A.id not in (".$tem.");";
$result=mysql_query($sql);
echo $sql."<br/>".$result."<br/>";
while ($rs=mysql_fetch_object($result))
{
echo $rs->id." ".$rs->member." ".$rs->product." ".$rs->other." ".$rs->price."<br/>";
}
?>