选择多个表时出错

error when selecting multiple tables

SELECT pc_info_tbl.`serial_id` "Serial Number",
       pc_info_tbl.`replacement_warranty_date` "Replacement Warranty",
       pc_info_tbl.`service_warranty_date` "Service Warranty",
       personel_tbl.`fname` "First Name",
       personel_tbl.`mname` "Middle Name",
       personel_tbl.`lname` "Last Name",
       repair_records_tbl.`repair_date` "Repair Date",
       repair_records_tbl.`service_slip_no` "Service Slip Number",
       repair_records_tbl.`itmd_personel_id` "ITMD Personnel",
       repair_records_tbl.`notes` "Notes"
  FROM repair_records_tbl,
       itmd_personel_tbl,
       pc_info_tbl,
       personel_tbl
 WHERE repair_records_tbl.`personel_id` = personel_tbl.`personel_id`,
       repair_records_tbl.`serial_id` = pc_info_tbl.`serial_id`,
       repair_records_tbl.`itmd_personel_id` = itmd_personel_tbl.`itmd_personel_id`;

我想 select 多个表,但我在 repair_records_tbl.`serial_id` = pc_info_tbl.`serial_id`, repair_records_tbl.`i

的某些地方出现错误

错误代码:1064 您的 SQL 语法有误;查看与您的 MySQL 服务器版本对应的手册,了解在 ' repair_records_tbl.serial_id = pc_info_tbl.serial_id, [=10= 附近使用的正确语法].`i' 在第 5 行

谁能教我正确的语法?

您在执行 select 时用逗号分隔列名,但在两个 clauses 之间使用 AND/OR 而不是用逗号分隔它们:

SELECT pc_info_tbl.`serial_id` "Serial Number", pc_info_tbl.`replacement_warranty_date` "Replacement Warranty", pc_info_tbl.`service_warranty_date` "Service Warranty", personel_tbl.`fname` "First Name", personel_tbl.`mname` "Middle Name", personel_tbl.`lname` "Last Name", repair_records_tbl.`repair_date` "Repair Date", repair_records_tbl.`service_slip_no` "Service Slip Number", repair_records_tbl.`itmd_personel_id` "ITMD Personnel", repair_records_tbl.`notes` "Notes" 
FROM repair_records_tbl, itmd_personel_tbl, pc_info_tbl, personel_tbl 
WHERE repair_records_tbl.`personel_id` = personel_tbl.`personel_id`
AND repair_records_tbl.`serial_id` = pc_info_tbl.`serial_id`
AND repair_records_tbl.`itmd_personel_id` = itmd_personel_tbl.`itmd_personel_id`;

您的 where 子句有语法错误。可能你想使用 AND

变化

WHERE repair_records_tbl.`personel_id` = personel_tbl.`personel_id`, 
      repair_records_tbl.`serial_id` = pc_info_tbl.`serial_id`, 
      repair_records_tbl.`itmd_personel_id` = itmd_personel_tbl.`itmd_personel_id`;

:

WHERE 
      repair_records_tbl.`personel_id` = personel_tbl.`personel_id`
  and repair_records_tbl.`serial_id` = pc_info_tbl.`serial_id`
  and repair_records_tbl.`itmd_personel_id` = itmd_personel_tbl.`itmd_personel_id`;