$strSQL1 = "SELECT * FROM tbl_productpercent Left JOIN tbl_company ON tbl_productpercent.cp_id=tbl_company.cp_id Left JOIN tbl_productgroup ON tbl_productpercent.pg_id=tbl_productgroup.pg_id Left JOIN tbl_memberpercentprice ON tbl_productpercent.pp_id=tbl_memberpercentprice.ppp_id";
มันก็จะขึ้นมาแบบนี้ครับ
แต่ผมต้องการแบบว่า Code (SQL)
$strSQL1 = "SELECT * FROM tbl_productpercent Left JOIN tbl_company ON tbl_productpercent.cp_id=tbl_company.cp_id Left JOIN tbl_productgroup ON tbl_productpercent.pg_id=tbl_productgroup.pg_id Left JOIN tbl_memberpercentprice ON tbl_productpercent.pp_id=tbl_memberpercentprice.ppp_id WHERE mb_username = '".$_SESSION["UserID"]."'";
$strSQL1 = "SELECT * FROM tbl_productpercent Left JOIN tbl_company ON tbl_productpercent.cp_id=tbl_company.cp_id Left JOIN tbl_productgroup ON tbl_productpercent.pg_id=tbl_productgroup.pg_id Left JOIN tbl_memberpercentprice ON tbl_productpercent.pp_id=tbl_memberpercentprice.ppp_id";
$strSQL1 = "SELECT * FROM tbl_productpercent Left JOIN tbl_company ON tbl_productpercent.cp_id=tbl_company.cp_id Left JOIN tbl_productgroup ON tbl_productpercent.pg_id=tbl_productgroup.pg_id Left JOIN tbl_memberpercentprice ON tbl_productpercent.pp_id=tbl_memberpercentprice.ppp_id WHERE mb_username = '".$_SESSION["UserID"]."'";
$strSQL1 = "SELECT * FROM tbl_productpercent Left JOIN tbl_company ON tbl_productpercent.cp_id=tbl_company.cp_id Left JOIN tbl_productgroup ON tbl_productpercent.pg_id=tbl_productgroup.pg_id Left JOIN tbl_memberpercentprice ON tbl_productpercent.pp_id=tbl_memberpercentprice.ppp_id ";
$rs=$mysql->query( 'select mb_username from ตารางไหนก็ไม่รู้ whre mb_user='".$_SESSION["UserID"]."' limit 1");
if($rs->num_rows) $where =' WHERE mb_username = '".$_SESSION["UserID"]."' ";
else $where = '';
$strSQL1 = "SELECT * FROM tbl_productpercent Left JOIN tbl_company ON tbl_productpercent.cp_id=tbl_company.cp_id Left JOIN tbl_productgroup ON tbl_productpercent.pg_id=tbl_productgroup.pg_id Left JOIN tbl_memberpercentprice ON tbl_productpercent.pp_id=tbl_memberpercentprice.ppp_id " . $where;