Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

SQL Statement

$
0
0
Hi Everyone,

I currently have a sql statement that I am struggling to produce the right results. Any help would be appreciated.
I have two tables named Transactions and Vendors. The field in both tables that is the same is called VID. Some records in the transactions table do not have a VID associated with them.

Transactions table looks like this

ID | VID | PurchaserName | PurchaseDate
------------------------------------------------------
0 | 21 | Mountain Brewhouse | 11/10/2006
1 | 13 | Joe's Grill | 1/1/2013
2 | 21 | 123 Red Rock Cafe | 6/30/2010
3 | | Rhodes Steakhouse | 4/15/2007

Vendors table looks like this

VID | VendorName | VendorAddress
----------------------------------------
...
13 | Dairy House | 123 Dairy Road
...
21 | GSS Grocery | 22 Main Street


I am trying to get the PurchaserName from the Transactions table along with the correct Vendor Information so the results look like to following.

PurchaserName | VendorName | VendorAddress
---------------------------------------------------------
Mountain Brewhouse | GSS Grocery | 22 Main Street
Joe's Grill | Dairy House | 123 Dairy Road
123 Red Rock Cafe | GSS Grocery | 22 Main Street
Rhodes Steakhouse

Here is the sql statement

SELECT Transactions.PurchaserName, Vendors.VendorName,
Vendors.VendorAddress FROM Transactions INNER JOIN Vendors ON Transactions.VID =
Vendors.VID WHERE Transactions.PurchaseDate BETWEEN '11/30/2007' AND '1/12/2013'

Viewing all articles
Browse latest Browse all 42215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>