HOME > PHP > PHP Forum > [PHP] ช่วยด้วยค่ะ eror Select error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND time_id='1'' at line 1
[PHP] ช่วยด้วยค่ะ eror Select error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND time_id='1'' at line 1
$sql = "SELECT subject FROM value WHERE id={$ListValue['id']} AND time_id={$item_id[$i]}";
ผมว่ารูปแบบมันแปลก ๆ แต่ก็แก้ไม่ถูก
ปกติผมจะใช้แบบ
sql = 'SELECT subject FROM value WHERE id='.$ListValue['id'] .'AND time_id='.$item_id[$i];
SELECT * FROM tb_projectdetail LEFT JOIN tb_projectnumber ON tb_projectdetail.ref_projectNo = tb_projectnumber.numberID LEFT JOIN tb_projectname ON tb_projectdetail.ref_projectName = tb_projectname.nameID LEFT JOIN tb_projectdoc ON tb_projectdetail.ref_projectDoc = tb_projectdoc.docID LEFT JOIN tb_projectlocation ON tb_projectdetail.ref_projectLocation = tb_projectlocation.locationID LEFT JOIN tb_projecttime ON tb_projectdetail.ref_projectTime = tb_projecttime.timeID LEFT JOIN tb_projectctrl ON tb_projectdetail.ref_projectCtrl = tb_projectctrl.ctrlID LEFT JOIN tb_projectco ON tb_projectdetail.ref_projectCo = tb_projectco.coID LEFT JOIN tb_projecthotel ON tb_projectdetail.ref_projectHotel = tb_projecthotel.hotelID LEFT JOIN tb_projectbus ON tb_projectdetail.ref_projectCar = tb_projectbus.busID LEFT JOIN tb_projectadmin ON tb_projectdetail.ref_status = tb_projectadmin.idadmin WHERE tb_projectdetail.projectID =20