Solved

SQL Query on Access

Posted on 2001-08-04
5
126 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

728 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