cancel
Showing results for 
Search instead for 
Did you mean: 

Question about Select-Query from 3 tables

ng82si
Participant
0 Kudos

Dear Experts,

I have a scenario: SQL--> IDoc.

In the SQL DB there are 3 tables:

- OrderHeader

      Index (Primary-Key), OrderID, Date, CustomerID....

- OrderPostion

      Index, PosID, OrderID, (Primary-Keys), ItemID,  Quantity, Unit...

- StatusProtocol

      Index (Primary-Key), Status, Type, SenderSys, ReceiverSys...

I'm not familiar with SQL-Query, how to select Orders from these 3 tables, it could be looked as below:

select OrderID, CustomerID, Date from OrderHeader and select PosID, ItemID, Quantity .. from OrderPostion where Index = Index and Index in (Select Index from StatusProtocol where Status=Ready, Type = Order, SenderSys = ExternApp...)

After selection the Status of the table StatusProtocol must be updated to Finished.

Could anyone give me a hand?

Hope you can understand me.

Thank u very much and Regards

Christine

Accepted Solutions (1)

Accepted Solutions (1)

former_member184720
Active Contributor
0 Kudos

Can you try with below?

select OrderHeader.OrderID,OrderHeader.CustomerID,OrderHeader.Date,OrderPostion.PosID,OrderPostion.ItemID,OrderPostion.Quantity from OrderHeader JOIN OrderPostion on

OrderHeader.Index = OrderPostion.Index and OrderPostion.Index in

(Select StatusProtocol.Index from StatusProtocol where SStatusProtocol.status='Ready', StatusProtocol.Type = 'Order', StatusProtocol.SenderSys = 'ExternApp')

ng82si
Participant
0 Kudos

thank u very much!

Answers (0)