任何人都可以發現我的語法錯誤嗎?我是新的SQL查詢。此代碼是在我的項目在其他地方使用,我重新格式化它我創建的新表,但我得到了下面的錯誤吧:找不到sql語法錯誤
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 'FROM tbl_prescriptions ta, tbl_prescriptions_type tat, tbl_prescriptions_subtype' at line 1 QUERY:SELECT ta.pk_id, ta.date, tat.vch_type as vch_type_name, tar.vch_subtype as vch_subtype_name, concat(tas.vch_first_name, ' ', tas.vch_last_name) as vch_resource_name, FROM tbl_prescriptions ta, tbl_prescriptions_type tat, tbl_prescriptions_subtype tar, tbl_resources tas WHERE ta.fk_type_id = tat.pk_id AND ta.fk_resource_id = tas.pk_id AND ta.fk_subtype_id = tar.pk_id AND ta.fk_patient_id = 359 ORDER BY date DESC;
$sqlPrescriptionQuery = "SELECT ta.pk_id, ta.date, ";
$sqlPrescriptionQuery .= "tat.vch_type as vch_type_name, ";
$sqlPrescriptionQuery .= "tar.vch_subtype as vch_subtype_name, ";
$sqlPrescriptionQuery .= "concat(tas.vch_first_name, ' ', tas.vch_last_name) as vch_resource_name, ";
$sqlPrescriptionQuery .= "FROM tbl_prescriptions ta, tbl_prescriptions_type tat, tbl_prescriptions_subtype tar, tbl_resources tas ";
$sqlPrescriptionQuery .= "WHERE ";
$sqlPrescriptionQuery .= "ta.fk_type_id = tat.pk_id AND ";
$sqlPrescriptionQuery .= "ta.fk_resource_id = tas.pk_id AND ";
$sqlPrescriptionQuery .= "ta.fk_subtype_id = tar.pk_id AND ";
$sqlPrescriptionQuery .= "ta.fk_patient_id = ".$row['pk_id']." ";
$sqlPrescriptionQuery .= "ORDER BY date DESC;";
$counter = 0;
$prescriptionresult = mysql_query($sqlPrescriptionQuery) or die(mysql_error()."<br>QUERY:".$sqlPrescriptionQuery);
謝謝!
逗號而來?也許如果你沒有把那些垃圾放在那裏,你會發現它自己 – Strawberry