Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004
    Posts
    9

    Unanswered: Subtracting tables

    I have two tables in a database. One of them contains the received stock and the other the sold stock. So the current stock is received stock-sold stock. But how do I put this into an SQL statment. What I would like to do basically, is subtract the sold stock table from the received stock table. I tried:

    SQLQuery = "select stock.* from stock inner join sold on not stock.serialnr=sold.serialnr"

    But it doesnt work. Inner join does the opposite: it adds the databases. I was wondering if there is a way to invert this operation.

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Code:
    SQLQuery = "SELECT Stock.Received-Sold.Units FROM Stock JOIN Sold on stock.serialnr=sold.serialnr"
    I am assuming the column names Received and Units, change those columns to fit your tables.
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

Posting Permissions

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