Solved

SQL Query on Access

Posted on 2001-08-04
5
125 Views
Last Modified: 2010-05-02
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
Comment
Question by:rian
5 Comments
 
LVL 2

Expert Comment

by:GregJennings
ID: 6352177
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
 
LVL 3

Expert Comment

by:Hornet241
ID: 6352407
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
 

Author Comment

by:rian
ID: 6352424
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
 
LVL 2

Expert Comment

by:Lunchy
ID: 6352455
rian, I deleted your duplicate question.

Lunchy
Friendly Neighbourhood Community Support Moderator

0
 
LVL 4

Accepted Solution

by:
ravi_raj123 earned 100 total points
ID: 6352822
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now