I need product Stock quantity from two tables

I have two tables, how to find stock from both tables? I work on VB.Net, if possible please help me.

Here's the relevant data from the link:

I HAVE TWO TABLES

  1. product_in (store all product QTY)
  2. product_out (store all products sold QTY)

first table (PRODUCT_IN) has following values:

Product Code(PK)     Description                QTY
RS121102             SUITS                      100
RS129985             SUITS                      100
DF-C09               SHIRTS                     50
AE-H05               SHIRTS                     50

Second table (PRODUCT_OUT) has following values:

Product Code         Description                QTY
RS121102             SUITS                      50
AE-H05               SHIRTS                     10

I WANT RESULT LIKE BELOW

Product Code         Description     Total QTY           Sold QTY
RS121102             SUITS                100               50
RS129985             SUITS                100               0
DF-C09               SHIRTS               100               0
AE-H05               SHIRTS               100               10

Answers


The query needed for you request is the following

SELECT a.[Product Code], a.Description, a.QTY as [Total QTY], b.QTY as [Sold QTY]
FROM PRODUCT_IN as a LEFT JOIN PRODUCT_OUT as b on a.[Product Code] = b.[Product Code]

By the way, if it is possible remove the spaces between field names. It forces to create unnecessary complicated queries.


Need Your Help

Trouble on finding a class object in a array of classes

ruby-on-rails ruby arrays ruby-on-rails-3 finder

I am using Ruby on Rails 3.0.7 and I would like to understand how to handle the following code in order to retrieve a class objects with a specified id.

Calling ActionScript 2.0 events from another project

actionscript-2

I have an ActionScript 2.0 file that contains a small library.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.