|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have 3 inventory tables: Computer, Server and Printer. each tables primary key is a autonumber
I have 3 data reports that list the inventory in each that use a SQL query to do it. such as Select ProductType, ProductName, UnitsInStock FROM ComputerInventory ORDER BY ProductType Is there a way to create a report that can combine all those and list the inventory in all 3 tables, in essence a total inventory report? i'm not too keen on the data environment and reports but i'm just wondering if its possible. i'm not sure if i really need it but if its doable it might be nice to have Thanks |
|
#2
|
|||
|
|||
|
Look at the sql UNION statement.
|
|
#3
|
|||
|
|||
|
Yeah, check out the UNION, the JOIN and something else that I forgot the name of...
If you still need more help, hit me back. I headed a small team that wrote a VB/database application which managed an entire database including reports. I'll try to dig up the code for that, but I might have lost it in my last hard drive failure. |
|
#4
|
|||
|
|||
|
i tried the UNION thing, heres what i did in the sql builder for the reports
SELECT ComputerPartName, ComputerPartDesc, UnitsInStock FROM ComputerInventory ORDER BY ComputerPartName UNION SELECT ServerPartName, ServerPartDesc, UnitsInStock FROM ServerInventory ORDER BY ServerPartName UNION SELECT PrinterPartName, PrinterPartDesc, UnitsInStock FROM PrinterInventory ORDER BY PrinterPartName gave me a error saying UNION wasn't allowed I also tried this when i changed the autonumbered primary key of the 3 tables to the same field name of just PartNumber SELECT ComputerPartName.ComputerInventory, ComputerPartDesc.ComputerInventory, UnitsInStock.ComputerInventory, ServerPartName.ServerInventory, ServerPartDesc.ServerInventory, UnitsInStock.ServerInventory, PrinterPartName.PrinterInventory, PrinterPartDesc.PrinterInventory, UnitsInStock.PrinterInventory FROM ComputerInventory, ServerInventory, PrinterInventory WHERE (PartNumber.ComputerInventory = PartNumber.ServerInventory) AND (PartNumber.ServerInventory = PartNumber.PrinterInventory) AND (PartNumber.ComputerInventory = PartNumber.PrinterInventory) and i the above with just the computer and server tables and it didn't work either. I have a book called a guide to SQL and what i did looks just like whats in the book but its not coming out the same way. Any suggestions? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Creating a Report from 3 Tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|