Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
CyberShot
Starting Member
2 Posts |
Posted - 2010-07-30 : 14:01:39
|
| Which invoices have involved parts whose name contains "widget" or "whatsit"? Display the invoice number and invoice date. Sort output by invoice numberI have two tables, INVOICE which containInvoiceNbrInvoiceDtTotalPriceFK_CustomerIDFK_EMPIDandPARTPartNBRDescriptionCostSalesPriceThe description is the PART table contains the widget and whatsit. I am trying to make a query that displays them both. There should only be two rows returned. My where clause keeps failing when I try to return both. This is my query nowselect InvoiceNbr, InvoiceDtFROM INVOICE, PARTWHERE PART.Description = 'widget'AND PART.Description = 'Whatsit';This is returning zero rows. Is this the proper way to use a join? |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-07-30 : 14:03:48
|
| How are the INVOICE table and PART table related? I dont see any field that is common between the two. |
 |
|
|
harrisunderwork
Starting Member
4 Posts |
Posted - 2010-08-01 : 01:35:11
|
| @CyberShot - there is no relation between two tables (atleast I cannot see it) |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2010-08-01 : 02:27:45
|
| You're going to need to find out how they're related (maybe via a third table) if you want all invoices that have those parts. Without a join, you have a Cartesian product - all possible combinations of invoice and part, which I don't think is what you want.p.s. Is this homework? Kinda looks like it.--Gail ShawSQL Server MVP |
 |
|
|
CyberShot
Starting Member
2 Posts |
Posted - 2010-08-01 : 02:33:12
|
| yes it is homework. I think I figured it though. |
 |
|
|
|
|
|