Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 128
  • Last Modified:

SQL Query on Access

I need to determine how to setup a Access query.

I have a item database with say 300 items. I also have an inventory file which is based on location information.

THe query below needs to display all the items from the item file using the inventory information selected for that location.

However when I run this query, I only get records which have information in the inventory file. Not all of them. I have even tried RIGHT JOIN. Access does not have OUTER JOIN.


SELECT Item.SKU, Item.Class, Item.Itemdescription AS Description,
Item.ItemSize AS [Size], Inventory.StartInventory AS [Start Inventory], Inventory.EndInventory AS [End Inventory] From Item, Inventory
LEFT JOIN Inventory ON  (Item.SKU = Inventory.SKU' and inventory.Location = 'GS1')
0
rian
Asked:
rian
1 Solution
 
GregJenningsCommented:
A RIGHT JOIN /is/ an OUTER JOIN; it's just the /type/ of outer join.

On one hand, you imply that you want an outer join of all the items regardless of inventory info ("...I only get records which have information in the inventory file."), but you also say you want only items with location 'GS1' ("The query below needs to display all the items from the item file using the inventory information selected for that location.").

These seem to be mutually exclusive.  If I am misunderstanding what data you want back from the database, please clarify.

Greg
0
 
Hornet241Commented:
I think this might work


SELECT Item.SKU, Item.Class, Item.Itemdescription AS Description,
Item.ItemSize AS [Size], Inventory.StartInventory AS [Start Inventory], Inventory.EndInventory AS [End
Inventory] From Item, Inventory
LEFT JOIN Inventory ON  Item.SKU = Inventory.SKU
Where inventory.Location = 'GS1'
0
 
rianAuthor Commented:
The Inventory table will have information of item and its stock in multiple locations. If there is no inventory information for that item, then the stock for that item is zero.
For example - I have 300 items in the item table. These items are available at all locations. THe inventory file could only have 100 inventory values for location 1, 50 for location 2 etc.

When I perform a query in access for location one, I need to display all 300 items with inventory information of 100 values on location 1. The rest will display all blank.

Hornet

It tried your query and Access does not allow that syntax.


0
 
LunchyCommented:
rian, I deleted your duplicate question.

Lunchy
Friendly Neighbourhood Community Support Moderator

0
 
ravi_raj123Commented:
HI,
Try this... here is a sample query

SELECT DISTINCTROW Titles.*, [Title Author].*
FROM Titles LEFT JOIN [Title Author] ON Titles.ISBN = [Title Author].ISBN

Here in this query, its displays the records which are in both the tables, and also the records which are in Titles table but are not have match in the [Title Author] table.

Hope this is clear.
Good Luck...:)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now