Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2013
    Posts
    29

    Unanswered: Link two "SELECT" instructions

    I have two tables with the same coulm but other contructions id field. I need to link from two to one instructions (tables are not in relations):

    Code:
    Select tblOrders.ID, tblOrders.JobName, tblOrders.Status from tblOrders WHERE tblOrders.status = 1 or tblOrders.status = 2 or tblOrders.status = 3
    and

    Code:
    Select tblworkOrders.ID, tblworkOrders.JobName, tblworkOrders.Status from tblworkOrders WHERE tblworkOrders.status = 1
    How can I do that?

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Sounds like you want a UNION query:
    Code:
    SELECT
       a.ID
    ,  a.JobName
    ,  a.Status
    FROM
       tblOrders AS a
    WHERE
       a.Status BETWEEN 1 AND 3
    UNION
    SELECT
       b.ID
    ,  b.JobName
    ,  b.Status
    FROM
       tblWorkOrders AS b
    WHERE
       b.Status = 1;
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •