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`;
我想选择多个表格,但是我在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
附近使用正确的语法,在第5行修复repair_records_tbl .i'
任何人都可以教我正确的语法吗?
答案 0 :(得分:1)
您的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`;
答案 1 :(得分:0)
您可以在使用逗号进行选择时分隔列名,但在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`;