I am trying to figure out how to get all tasks in this case that two of the fields equal a certain value or they exist in the other table?
Here is the query:
<
You seem to have an error in your syntax. You have too many WHERE
s:
SELECT t.task_id, t.task_title, t.task_description, t.task_assigned_name, t.task_assigned_phone_number, t.task_due_date_time, t.task_category
FROM TASKS t
WHERE t.task_complete = 1 AND
(t.task_creator_id = ? OR
t.task_assigned_user_id = ? OR
EXISTS (SELECT 1 -- the return value is immaterial
FROM WATCHERS w
WHERE w.task_id = t.task_id AND
w.watcher_user_id = ?
)
);
The WHERE
before EXISTS
is not appropriate.
Your query should be returning an error. Be sure to check for errors!