你好我正在尝试加入一个表Classes&员工一起使用外键" Employee_Id"从C表中获取E表中的名字和姓氏
SELECT class_id,
subject_name,
classes.employee_id
FROM schooladmindb.classes
INNER JOIN schooladmindb.employee
ON
where classes.employee_id = employee.employee_id;
我不确定我必须使用的声明才能获得" First_Name" &安培; "姓氏"从保持C表数据完整的E表
答案 0 :(得分:1)
您的语句错误,因为您不需要WHERE
加入两个表
检查 JOIN sintaxis
SELECT class_id,
subject_name,
classes.employee_id
FROM schooladmindb.classes
INNER JOIN schooladmindb.employee
ON classes.employee_id = employee.employee_id;
答案 1 :(得分:1)
是的,您只需添加名字和姓氏以及其他字段,例如
SELECT class_id,
subject_name,
employ_FirstName, // Column in your employee table
employ_LastName,
classes.employee_id
FROM schooladmindb.classes
INNER JOIN schooladmindb.employee
ON classes.employee_id = employee.employee_id;