Inner join 2 tables one to many 2 where clauses

Posted by user2892350 on Stack Overflow See other posts from Stack Overflow or by user2892350
Published on 2013-10-17T21:51:14Z Indexed on 2013/10/17 21:53 UTC
Read the original article Hit count: 151

Filed under:
|
|

I'm a relative rookie at this,so please bear with me...

I have 2 tables: OrderDetail and OrderMaster...both have a column named SalesOrder.

OrderDetail table has multiple rows per unique SalesOrder. OrderMaster table has one row per unique SalesOrder.

OrderDetail has a column named LineType. OrderMaster has a column named OrderStatus.

I want to select all records from OrderDetail that have a LineType of "1" AND whose matching SalesOrder line in the OrderMaster table has a OrderStatus column value of "4".

In plain English, orders with a Status 4 are open and ready to ship, LineType value of 1 means the Detail Line is a product code.

How should this query be structured? It's going into VS 2008 (VB).

Many thanks in advance!!!

Mike

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server