简体   繁体   中英

Subquery statement

I have two tables in a Mysql DB One has a list of options (actions) identified with Action_ID the other list is of the Tasks based on these actions ( for different jobs and in various states of completion )

I need a list of actions excluding the tasks already assigned to a specific job AND not yet completed .

i have these until now but get errors I did not manage to resolve yet :

    SELECT 
  * 
FROM
  Workshop_actions 
WHERE Action_ID IS NOT 
  (SELECT 
    Action_ID 
  FROM
    `Workshop_tasks` 
  WHERE W_job_ID = $ Job_ID 
    AND STATUS <> "F")

Being $Job_ID the specific job and F the status for Finished

SELECT * 
  FROM Workshop_actions a
  LEFT
  JOIN Workshop_tasks
    ON t.action_id = a.action_id
   AND W_job_ID = $Job_ID 
   AND Status <> "F"
 WHERE t.action_id IS NULL;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM