tags:

views:

50

answers:

1

I am pulling information from a table with multiple lines that all corrorpond to one ticket. If anywhere on the ticket I see a charge for MIlk I want to see all lines associated with that ticket#. I tried to write a subquery but that has not worked for me. Any ideas??

Example:

Item Cost

  1. Yams 1.0
  2. Beans 2.0
  3. Milk 5.0
  4. Yams 1.0
  5. Beans 2.0
  6. Candy 1.0
  7. Beans 2.0
  8. Yams 1.0
  9. Beans 2.0
  10. Milk 5.0
  11. Beans 2.0
  12. Milk 5.0
+1  A: 

Something like

select *
from Items
where TicketId in
  (
    select distinct TicketId
    from Items
    where ItemName = 'Milk'
  )

?

GalacticCowboy
About as good a guess as you can make given the total absence of information about the real schema in the question.
Jonathan Leffler