home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / t / tech91.zip / TI784.ASC < prev    next >
Text File  |  1991-08-26  |  5KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Paradox                                NUMBER  :  784
  9.   VERSION  :  3.0 & up
  10.        OS  :  DOS
  11.      DATE  :  August 26, 1991                          PAGE  :  1/3
  12.  
  13.     TITLE  :  Doing "Not-In" Queries in Paradox
  14.  
  15.  
  16.  
  17.  
  18.   This query is made to ask the question "What records exist in one
  19.   table that do NOT exist in another?"  The following is a general
  20.   example method for creating "Not-In" queries.
  21.  
  22.   Notice that this example uses the COUNT operation and it does not
  23.   use NOT or NO.  For the examples, an underscore character will be
  24.   used in place of the [F5] key to indicate an example element in
  25.   the query.
  26.  
  27.        First create tables with the structures shown below.
  28.  
  29.   CUSTOMER╦════Cust #═════╦════Last Name═════╦════First Name════╗
  30.        1  ║      1015     ║  Elkins          ║  Eugene          ║
  31.        2  ║      1020     ║  Fenton          ║  Mark            ║
  32.        3  ║      1055     ║  Harding         ║  Jim             ║
  33.        4  ║      1056     ║  Wilden          ║  Marc            ║
  34.        5  ║      1319     ║  Fenton          ║  Teresa          ║
  35.        6  ║      1341     ║  Goves           ║  Cynthia         ║
  36.        7  ║      1342     ║  Goves           ║  Joseph          ║
  37.        8  ║      1685     ║  Moon            ║  Yvonne          ║
  38.        9  ║      1988     ║  Martinez        ║  Susan           ║
  39.       10  ║      2022     ║  Staebell        ║  Alice           ║
  40.  
  41.  
  42.   ORDERS═╦════Order #════╦═════Date═════╦════Cust #═════╦Part #╦
  43.        1 ║         1     ║   7/09/89    ║      1015     ║  DR  ║
  44.        2 ║         2     ║   7/09/89    ║      1341     ║  WR  ║
  45.        3 ║         3     ║   7/09/89    ║      1685     ║  HA  ║
  46.        4 ║         4     ║   7/28/89    ║      1988     ║  HA  ║
  47.        5 ║         5     ║   8/01/89    ║      2022     ║  WR  ║
  48.        6 ║         6     ║   8/03/89    ║      1988     ║  GH  ║
  49.        7 ║         7     ║   8/04/89    ║      1341     ║  DR  ║
  50.        8 ║         8     ║   8/14/89    ║      1055     ║  VI  ║
  51.        9 ║         9     ║   8/15/89    ║      1020     ║  DR  ║
  52.       10 ║        10     ║   8/16/89    ║      1341     ║  GH  ║
  53.       11 ║        11     ║   8/18/89    ║      1015     ║  TB  ║
  54.       12 ║        12     ║   8/21/89    ║      1685     ║  TB  ║
  55.  
  56.   (The next table is a continuation of the above orders table)
  57.  
  58.   ORDERS═╦══════Price═══════╦
  59.        1 ║          46.20   ║
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Paradox                                NUMBER  :  784
  75.   VERSION  :  3.0 & up
  76.        OS  :  DOS
  77.      DATE  :  August 26, 1991                          PAGE  :  2/3
  78.  
  79.     TITLE  :  Doing "Not-In" Queries in Paradox
  80.  
  81.  
  82.  
  83.  
  84.        2 ║           3.96   ║
  85.        3 ║          12.04   ║
  86.        4 ║          12.04   ║
  87.        5 ║           3.96   ║
  88.        6 ║          14.52   ║
  89.        7 ║          46.20   ║
  90.        8 ║          65.93   ║
  91.        9 ║          46.20   ║
  92.       10 ║          14.52   ║
  93.       11 ║          33.66   ║
  94.       12 ║          33.66   ║
  95.  
  96.   The query shown below is how to ask the question "Which customers
  97.   have never placed an order?".  This query works for the following
  98.   reasons.  First, it uses the 'inclusion operator' which is the
  99.   exclamation point <!> in the [Cust #] field of the CUSTOMER
  100.   table.  This tells Paradox to consider every customer number,
  101.   whether or not it is found in the ORDERS table.
  102.  
  103.   Next, the ORDERS table contains the expression "count=0" in the
  104.   [Cust #] field.  This tells Paradox to count the number of
  105.   occurrences of each customer number in the ORDERS tables, and
  106.   only include those which occur zero times.  In other words, show
  107.   the customers who have not placed any orders, or show everything
  108.   in the CUSTOMER table that is NOT in the ORDERS table.
  109.  
  110.   ORDERS═╦Order #═╦══Date═══╦════Cust #════╦═Part #══╦══Price═══╗
  111.          ║        ║         ║  _c,count=0  ║         ║          ║
  112.          ║        ║         ║              ║         ║          ║
  113.          ║        ║         ║              ║         ║          ║
  114.  
  115.  
  116.   CUSTOMER╦═Cust #═╦═Last Name══╦═First Name═╗
  117.           ║√ _c!   ║            ║            ║
  118.           ║        ║            ║            ║
  119.           ║        ║            ║            ║
  120.  
  121.  
  122.   ANSWER═╦══Cust #═══╗
  123.        1 ║     1056  ║
  124.        2 ║     1319  ║
  125.        3 ║     1342  ║
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Paradox                                NUMBER  :  784
  141.   VERSION  :  3.0 & up
  142.        OS  :  DOS
  143.      DATE  :  August 26, 1991                          PAGE  :  3/3
  144.  
  145.     TITLE  :  Doing "Not-In" Queries in Paradox
  146.  
  147.  
  148.  
  149.  
  150.   To help understand how this query works, try changing the
  151.   "count=0" to a "calc count all".  The ANSWER that will be
  152.   returned will have 10 records, since there are 10 records in the
  153.   CUSTOMER table.  The number shown will be the number of times
  154.   each customer appears in the ORDERS table.  And you will see that
  155.   the records 1056, 1319 and 1342 show a count of zero, which are
  156.   the answer to the above query.
  157.  
  158.   The information in this document came from Brian J. Smith's
  159.   article "How To Ask 'Not-In' Queries" which first appeared in the
  160.   October 1989 issue of "Instant Scripts", a publication of the
  161.   LAPALS user group in Southern California.
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.