我正在使用MySql。 当我从表中选择多列时
responsible_id,标题
然后生成错误。 所以我不会选择多列。请帮我解决这个问题。
select id,
title,
responsible_id,
project_id p_id,(select responsible_id,title from projects where p_id=projects.project_id) responsible_id,
status,
create_by,
milestone_id from tasks
答案 0 :(得分:2)
您不能以这种方式从相关子查询中选择多个列。
JOIN
改为两个表,如下所示:
select
t.id,
t.title AS TaskTitle,
t.responsible_id,
p.project_id p_id,
p.responsible_id,
p.title AS ProjectTitle,
t.status,
t.create_by,
t.milestone_id
from tasks AS t
INNER JOIN projects AS p ON t.p_id = p.project_id