gpt4 book ai didi

mysql - MySQL 中的一个查询

转载 作者:行者123 更新时间:2023-11-29 01:55:49 27 4
gpt4 key购买 nike

我想获取所有每小时付薪 17.5 的员工,项目名称是 HR System。

employee table: employee_id (PK), employee_name
project table: project_code (PK), project_title
project_team: project_code (FK), employee_id (FK), hourly_rate

我尝试了以下查询,但出现语法错误。我哪里做错了?

SELECT employee.`department_id`, employee.`employee_name`, project_team.`hourly_rate`, project.`project_title`
FROM
(employee INNER JOIN project_team ON employee.`employee_id` = project_team.`employee_id`)
AND
(project INNER JOIN project_team ON project.`project_code` = project_team.`project_code`)
AND
(project_team.`hourly_rate` = 17.50)
AND
(project.`project_title` = "HR System");

最佳答案

使用这个语句

SELECT employee.`department_id`, employee.`employee_name`, project_team.`hourly_rate`, project.`project_title`
FROM employee
INNER JOIN project_team ON employee.`employee_id` = project_team.`employee_id`
inner join project ON project.`project_code` = project_team.`project_code`
where
(project_team.`hourly_rate` = 17.50)
AND
(project.`project_title` = "HR System");

您不能在 from 子句中使用 AND。您必须使用正确的 join 语法。

关于mysql - MySQL 中的一个查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29674345/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com