If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Subtracting tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-01-04, 17:25
Triple A Triple A is offline
Registered User
 
Join Date: May 2004
Posts: 9
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.
Reply With Quote
  #2 (permalink)  
Old 08-02-04, 18:31
SCIROCCO SCIROCCO is offline
Registered User
 
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!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On