このクエリは機能します:
var query = knex('project_member')
.join('project', 'project_member.pm_project', '=', 'project.prj_id')
.join('users', 'project_member.pm_user', '=', 'users.us_id')
.where({
prj_number: inputs.params.prj_number
})
.select('pm_project', 'us_name', 'us_alias');
query.toString() は以下を与えます:
select "pm_project", "us_name", "us_alias" from "project_member" inner join "project" on "project_member"."pm_project" = "project"."prj_id" inner join "users" on "project_member"."pm_user" = "users"."us_id" where "prj_number" = '4026305'
このクエリは機能しません:
var query = knex('project_member')
.join('project', 'project_member.pm_project', '=', 'project.prj_id')
.where({
prj_number: inputs.params.prj_number,
pm_user: inputs.params.pm_user
})
.del();
query.toString() は以下を与えます:
delete from "project_member" where "prj_number" = '4026305' and "pm_user" = '1'
削除クエリで結合を使用することはできませんか? それらに参加するには、別のクエリを作成する必要がありますか?