$sql="SELECT tb_asset.owner FROM tb_company INNER JOIN tb_asset ON tb_company.company_name Operater tb_asset.owner WHERE owner='$_GET[select]' AND year='$_GET[year_as]' AND company='$_GET[company]' ";
ติดตรงรับค่า ส่วน WHERE แบบ $_GET แล้วให้ SELECT ข้อมูล ออกมา
$sql ="SELECT * FROM tb_company INNER JOIN tb_asset ON tb_company.comp_id = tb_asset.as_id WHERE owner='".$_GET[select]."' ";
$sql .="AND year='".$_GET[year_as]."' AND company='".$_GET[company]."' ";
Code (PHP)
Error Query = SELECT tb_asset.owner FROM tb_company INNER JOIN tb_asset ON tb_company.company_name Operater tb_asset.owner WHERE owner='TOS' AND year='2555' AND company='[TOS] Toscana Valley Co.,Ltd'
Error Query = SELECT tb_asset.owner FROM tb_company INNER JOIN tb_asset ON tb_company.company_name Operater tb_asset.owner WHERE owner='TOS' AND year='2555'' AND company='[TOS] Toscana Valley Co.,Ltd'
$sql = "SELECT tb_asset.owner FROM tb_company INNER JOIN tb_asset ON tb_company.company_name = tb_asset.owner WHERE owner='TOS' AND year='2555' AND company='[TOS] Toscana Valley Co.,Ltd' ";
Syntax
SELECT * FROM table1 INNER JOIN table2 ON table1.primary_key = table2.foreign_key ;
Code (PHP)
SELECT * FROM tb_company INNER JOIN tb_asset ON tb_company.comp_id = tb_asset.as_id WHERE owner='".$_GET[select]."'
SELECT * FROM tb_company INNER JOIN tb_asset ON tb_company.comp_id= tb_asset.as_id WHERE owner='TOS' AND year='2555' AND company='[TOS] Toscana Valley Co.,Ltd'
SELECT tb_company.*, tb_asset.* FROM tb_company INNER JOIN tb_asset ON tb_company.comp_id= tb_asset.as_id WHERE owner='TOS' AND year='2555' AND company='[TOS] Toscana Valley Co.,Ltd'
SELECT * from tb_asset.owner
WHERE tb_asset.owner='$_GET[select]'
AND tb_asset.year='$_GET[year_as]' # ถ้ามี ฟีลด์ year อยู๋ด้วย
AND tb_asset.company='$_GET[company]' # ถ้ามี ฟีลด์ company อยู๋ด้วย
และ
SELECT * FROM tb_company
WHERE tb_company.company='$_GET[select]'
AND tb_company.year='$_GET[year_as]' # ถ้ามี ฟีลด์ year อยู๋ด้วย
AND tb_company.company='$_GET[company]' # ถ้ามี ฟีลด์ company อยู๋ด้วย