SQL SELECT + INNER JOIN + WHERE

时间:2014-06-10 15:01:47

标签: mysql sql database postgresql

所以我有这个查询,可以“看看有什么不对”

SELECT tasks.id,tasks.client_name,tasks.description,tasks.state, 
       tasks.planned_dates, tasks.task_for, tasks.task_type, 
       tasks.solution, tasks.created_by, users.color 
FROM public.tasks 
INNER JOIN public.users ON (tasks.created_by = users.id) 
WHERE id IN 
(
  SELECT tt.id 
  FROM (
    SELECT id, unnest(planned_dates) as dd 
    FROM tasks 
    WHERE planned_dates IS NOT NULL AND deleted = FALSE
  ) as tt 
  WHERE tt.dd BETWEEN @startdate AND @enddate
)

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

如果没有看到你得到的错误,很难分辨。但从查看您的查询可能是

WHERE id IN 

含糊不清。尝试使用tasks.id代替id(或users.id,如果您的意思是id)