Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select statement problem

Status
Not open for further replies.

Sql7user

MIS
Oct 2, 2002
16
SE
Hi,

I have a problem with a select statement that I have no idea how to solve.

I´m going to try to explain the problem. I have a query where the fields are: Article Nr, Machine, Batch, Material Nr, Quantity.

I have some creterias where I can search out for example, all batches for a specific article nr. or all batches made for a specifik time period. This work without no problem.
The problem comes when i want to search out all batches made with a specific machine. And some batches can go throw more than one matchine. Lets say a batch goes throw machine 1, 2, 3. If I put a creteria that say I want all batches made by machine 2 I only get those steps and material that been made by machine 2. Instead I want all batches thats been made by machine 2 but also see what other matchines has been involved in the batch.

I hope you understand my problem and I would be very thankful if someone could help me with this.

/Sql7user
 
SELECT * from myTable where machine like '%2%'

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Try this
Code:
Select Item, Batch, Machine
From tbl T
Where EXISTS (Select * From tbl X Where X.Item = T.Item AND X.Machine = 2)
 
Thanks too both of you for your good solutions.

/Sql7user
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top