Professional Web Applications Themes

SQL Syntax Question??? - Macromedia Dreamweaver

I have 2 tables. One that has all my products (table1) and another table that matches my products with a invoice number (table2). What I want to do is extract all the products that don't belong to a invoice based on the info in table2. Basically I want to extract all the products that have never been ordered. Here is the join I have but it doesn't seem to work. SELECT * FROM Lots, ShipLots WHERE Lots.ID <> ShipLots.ShipmentID ORDER BY Lots.ID DESC Thanks...

  1. #1

    Default SQL Syntax Question???

    I have 2 tables. One that has all my products (table1) and another table
    that matches my products with a invoice number (table2).

    What I want to do is extract all the products that don't belong to a invoice
    based on the info in table2.

    Basically I want to extract all the products that have never been ordered.
    Here is the join I have but it doesn't seem to work.

    SELECT *
    FROM Lots, ShipLots
    WHERE Lots.ID <> ShipLots.ShipmentID
    ORDER BY Lots.ID DESC

    Thanks


    Kory Guest

  2. #2

    Default Re: SQL Syntax Question???

    This should work for you:

    SELECT ID
    FROM LOTS
    WHERE ID NOT IN (SELECT ShipmentID FROM ShipLots)
    ORDER BY ID DESC

    This will return the ID's that are not in the second table.

    Let me know if that does the trick.

    craig v



    "Kory" <koryc5designs.com> wrote in message
    news:bekm8c$lqk$1forums.macromedia.com...
    I have 2 tables. One that has all my products (table1) and another table
    that matches my products with a invoice number (table2).

    What I want to do is extract all the products that don't belong to a invoice
    based on the info in table2.

    Basically I want to extract all the products that have never been ordered.
    Here is the join I have but it doesn't seem to work.

    SELECT *
    FROM Lots, ShipLots
    WHERE Lots.ID <> ShipLots.ShipmentID
    ORDER BY Lots.ID DESC

    Thanks



    craig v Guest

  3. #3

    Default Re: SQL Syntax Question???

    that did it!

    Thanks

    "craig v" <craig765spamless-> wrote in message
    news:bekpp7$r7i$1forums.macromedia.com...
    > This should work for you:
    >
    > SELECT ID
    > FROM LOTS
    > WHERE ID NOT IN (SELECT ShipmentID FROM ShipLots)
    > ORDER BY ID DESC
    >
    > This will return the ID's that are not in the second table.
    >
    > Let me know if that does the trick.
    >
    > craig v
    >
    >
    >
    > "Kory" <koryc5designs.com> wrote in message
    > news:bekm8c$lqk$1forums.macromedia.com...
    > I have 2 tables. One that has all my products (table1) and another table
    > that matches my products with a invoice number (table2).
    >
    > What I want to do is extract all the products that don't belong to a
    invoice
    > based on the info in table2.
    >
    > Basically I want to extract all the products that have never been ordered.
    > Here is the join I have but it doesn't seem to work.
    >
    > SELECT *
    > FROM Lots, ShipLots
    > WHERE Lots.ID <> ShipLots.ShipmentID
    > ORDER BY Lots.ID DESC
    >
    > Thanks
    >
    >
    >

    Kory Guest

Similar Threads

  1. Question about E4X syntax.
    By rpierich in forum Macromedia Flex General Discussion
    Replies: 7
    Last Post: May 27th, 06:12 AM
  2. Question on syntax...
    By Jonathan Villa in forum PHP Development
    Replies: 1
    Last Post: August 20th, 03:15 PM
  3. [PHP] Question on class syntax
    By Luis Lebron in forum PHP Development
    Replies: 3
    Last Post: August 7th, 07:07 PM
  4. Question on class syntax
    By Greg Beaver in forum PHP Development
    Replies: 0
    Last Post: August 7th, 06:34 PM
  5. Transact-SQL syntax question
    By Rajan Murthy in forum Microsoft SQL / MS SQL Server
    Replies: 2
    Last Post: July 1st, 03:36 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139