•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 422,412 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,046 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 1248 | Replies: 9 | Solved
![]() |
•
•
Join Date: Dec 2007
Posts: 27
Reputation:
Rep Power: 1
Solved Threads: 0
Dear Friend
I am trying to perform the flowing tasks using the following SQL statement in Microsoft Access but they don’t work. I wonder if someone could help and tell me what is wrong with my Statements. Whenever I run these statements it will not create the query.
Task 1: Formulate a query and prepare a report to find order details for a selected warehouse on a specific date, this will help the warehouse gather and pack all goods ready for the courier.
SQL statement I am using is:
SELECT * FROM Order WHERE WarehouseID='Manchester' AND Date='02/06/2008';
Task2: Formulate a query and prepare a report so that a specific warehouse can check their stock if any quantities of stock fall below 5, stock description should also be listed.
SQL statement I am using is:
SELECT* Description, ProductsID FROM Products WHERE Qty < 5;
Kind Regards
HB25
I am trying to perform the flowing tasks using the following SQL statement in Microsoft Access but they don’t work. I wonder if someone could help and tell me what is wrong with my Statements. Whenever I run these statements it will not create the query.
Task 1: Formulate a query and prepare a report to find order details for a selected warehouse on a specific date, this will help the warehouse gather and pack all goods ready for the courier.
SQL statement I am using is:
SELECT * FROM Order WHERE WarehouseID='Manchester' AND Date='02/06/2008';
Task2: Formulate a query and prepare a report so that a specific warehouse can check their stock if any quantities of stock fall below 5, stock description should also be listed.
SQL statement I am using is:
SELECT* Description, ProductsID FROM Products WHERE Qty < 5;
Kind Regards
HB25
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
Dear friend
One can help you only if you show the corresponding data model your tasks are based on!
krs,
tesu
p.s. your selects seem to be rather imperfect.
•
•
•
•
. . .
Task 1: Formulate a query and prepare a report to find order details for a selected warehouse on a specific date, this will help the warehouse gather and pack all goods ready for the courier.
Task2: Formulate a query and prepare a report so that a specific warehouse can check their stock if any quantities of stock fall below 5, stock description should also be listed.
. . .
HB25
One can help you only if you show the corresponding data model your tasks are based on!
krs,
tesu
p.s. your selects seem to be rather imperfect.
Last edited by tesuji : Jun 4th, 2008 at 4:20 pm.
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
Hi HB25,
Your first select should look like:
I didn't test it. It should work on all databases which supply standard SQL 1999. As far as I know, Access also supports inner joins. If not, let me know. In this case the joins must be replaced.
Btw, there should be done some improvement of your data model:
There must be an 1:m relationship between Stock and Product: Stock ->------- Product
Primary key of Item must be ProductID and OrderID (the thing with composite and foreign keys)
What is CustID of Item?
Table name Order should be replaced by another name because ORDER is SQL word ( ORDER BY ...)
krs,
tesu
Your first select should look like:
sql Syntax (Toggle Plain Text)
SELECT c.CustomerID, c.Surname, c.Address, c.Town, c.Postcode, o.OrderID, o.Date, i.ProductID, i.Qty, p.Description FROM Customer c JOIN ORDER o ON c.CustomerID = o.CustomerID JOIN Item i ON o.OrderID = i.OrderID JOIN Product p ON i.ProductID = p.ProductID WHERE WarehouseID='Manchester' AND Date='02/06/2008'
Btw, there should be done some improvement of your data model:
There must be an 1:m relationship between Stock and Product: Stock ->------- Product
Primary key of Item must be ProductID and OrderID (the thing with composite and foreign keys)
What is CustID of Item?
Table name Order should be replaced by another name because ORDER is SQL word ( ORDER BY ...)
krs,
tesu
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
•
•
•
•
... I have tried your code but it does have a problem with the word (join)...
HB25
Sorry, I thought Access would have been able to handle joins. The inner joins you need can be replaced by cross products and join conditions in where clause, try this:
sql Syntax (Toggle Plain Text)
SELECT c.CustomerID, c.Surname, c.Address, c.Town, c.Postcode, o.OrderID, o.Date, i.ProductID, i.Qty, p.Description FROM Customer c, ORDER o, Item i, Product p WHERE c.CustomerID = o.CustomerID AND o.OrderID = i.OrderID AND i.ProductID = p.ProductID AND WarehouseID='Manchester' AND Date='02/06/2008'
tesu
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 1
•
•
•
•
Dear Friend
Task 1: Formulate a query and prepare a report to find order details for a selected warehouse on a specific date, this will help the warehouse gather and pack all goods ready for the courier.
SQL statement I am using is:
SELECT * FROM Order WHERE WarehouseID='Manchester' AND Date='02/06/2008';
Task2: Formulate a query and prepare a report so that a specific warehouse can check their stock if any quantities of stock fall below 5, stock description should also be listed.
SQL statement I am using is:
SELECT* Description, ProductsID FROM Products WHERE Qty < 5;
Task 1
SQL Syntax (Toggle Plain Text)
SELECT Customer.CustomerID, Customer.Surname, Customer.Address, Customer.Town, Customer.[Post code], ORDER.OrderID, ORDER.Date, Item.[Products ID], Item.Qty, Products.Description, Products.[Unit Price], ORDER.WarehouseID FROM Products INNER JOIN ((Customer INNER JOIN [ORDER] ON Customer.CustomerID = ORDER.CustomerID) INNER JOIN Item ON ORDER.OrderID = Item.[ORDER ID]) ON Products.ProductsID = Item.[Products ID] WHERE (((ORDER.Date)=#2/6/2008#) AND ((Order.WarehouseID)="Manchester"));
Task 2
SQL Syntax (Toggle Plain Text)
SELECT Description, ProductsID FROM Products WHERE Qty < '5';
Your table has the quantity field set as type text, so the statment where Qty <5 will not work. You can either change the type of field and use the original where clause or use the one above. Please note that the original Select had a syntax error you should drop the *.
Regards
TCBW
Last edited by TCBW : Jun 5th, 2008 at 12:57 pm. Reason: Formating
•
•
Join Date: Dec 2007
Location: Oklahoma
Posts: 161
Reputation:
Rep Power: 1
Solved Threads: 16
looking in your db i noticed that you do not have any orders in February. This will be one reason why you cant pull anything from the first query. change the date to 6/2/2008 and BAM its full of data
the second query works good with this
sql Syntax (Toggle Plain Text)
SELECT Customer.*, ORDER.* FROM Customer INNER JOIN [ORDER] ON Customer.CustomerID = ORDER.CustomerID WHERE (((ORDER.Date)=#6/2/2008#) AND ((Order.WarehouseID)="manchester"));
the second query works good with this
sql Syntax (Toggle Plain Text)
SELECT * FROM Products WHERE (((Qty)<"5"));
Last edited by ProfessorPC : Jun 6th, 2008 at 12:40 am.
•
•
Join Date: Dec 2007
Posts: 27
Reputation:
Rep Power: 1
Solved Threads: 0
Dear friend (ProfessorPC , TCBW, tesuji)
Thank you very much for all your comment and suggestion, I have managed to perform both of my tasks using the fallowing SQL command fallowing your suggestions. You guys did a fantastic job
Task 1 solution:
Task2 solutions:
I have opened a new thread (http://www.daniweb.com/forums/post62...2145)regarding Report in Microsoft access I wonder if you guys could help on that as well, this will be the last requirement I have to do. Any suggestion, comment and advice will be really appreciated.
Kind Regards
HB25
Thank you very much for all your comment and suggestion, I have managed to perform both of my tasks using the fallowing SQL command fallowing your suggestions. You guys did a fantastic job
Task 1 solution:
sql Syntax (Toggle Plain Text)
SELECT Customer.CustomerID, Customer.Surname, Customer.Address, Customer.Town, Customer.[Post code], ORDER.OrderID, ORDER.Date, ORDER.WarehouseID FROM Customer INNER JOIN [ORDER] ON Customer.CustomerID = ORDER.CustomerID WHERE (((ORDER.Date)=#6/2/2008#) AND ((Order.WarehouseID)="manchester"));
Task2 solutions:
sql Syntax (Toggle Plain Text)
SELECT [Stock].[WareHouseID], [Stock].[ProductsID], [Stock].[Qty], [Products].[Description] FROM Stock INNER JOIN Products ON [Stock].[ProductsID]=[Products].[ProductsID] WHERE ((([Stock].[Qty])<5) AND (([Stock].[WarehouseID])="London"));
I have opened a new thread (http://www.daniweb.com/forums/post62...2145)regarding Report in Microsoft access I wonder if you guys could help on that as well, this will be the last requirement I have to do. Any suggestion, comment and advice will be really appreciated.
Kind Regards
HB25
Last edited by peter_budo : Jun 15th, 2008 at 11:25 am. Reason: Keep It Organized - please use [code] tags
![]() |
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access ajax apple browser business code computer console database development drm exploit firefox game google hardware ibm internet ip ipod linux merger microsoft mobile mozilla news novell office openoffice operating os pc red hat search security software spyware sql survey system ubuntu upgrade virus vista web windows xbox 360 xp yahoo zune
- Shopping Cart Not Working (ASP.NET)
- DataBase connection in Jsp to MS-Access (JSP)
- Syntax error in INSERT INTO statement (Java)
- how to create new table in MS Access2003 database using VB6 (Visual Basic 4 / 5 / 6)
- Please help(Problem in insertion data to database) (JSP)
- SQL problem - table names as variables (MS SQL)
- Posting News according to today's date (ColdFusion)
- Microsoft Jet 4.0 Service Pack 8 problem (Windows Software)
- ODBC setup with Online Access DB (MS Access and FileMaker Pro)
Other Threads in the MS SQL Forum
- Previous Thread: populating listview from databases
- Next Thread: MS SQL query using Max


Linear Mode