Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Q: sql query where criteria is not all contained in each row
hi,
I'm having trouble finding an elegant solution to a problem using sql.
I'm trying to run a query to select a set of rows from a table, but the criteria for each row is not wholly contained in the row. Here are the details:
Table: invoice_detail
invoice_detail_id (PK) invoice_id (FK) product_id (FK)
So, for each product that an invoice contains, there is a row in this table. Now, my problem is how do i select All invoices that contain the products 002 _and_ 005.
SELECT * FROM invoice_detail WHERE product_id = 002 AND product_id = 005
obviously won't work, since product_id cannot be two values at once. I realize that there probably needs to be two separate queries with some sort of join but am stuck. Any tips or pointers would be greatly appreciated!
-john
Received on Sun Aug 02 1998 - 13:03:00 CDT
![]() |
![]() |