Если еще условие, как использовать в запросе select?
`i want a query in which if and else will use but i do not know how it will use,below is my table structure ,i want result below mentioned after Produce table ,,please help thanks....` >Item Master Table `item_code Item_Name Weight UOM 1001 Pen 44 unit 1002 Computer 42 unit` Customer Table ` Customer_ID Customer_Name Contact Address 1 Akhter 3434 3434 2 Hussain 333 555` Customer Item Table `Customer_ItemCode Customer_ItemName Item_code(FK) Weight Customer_ID(FK) 2001 Pen America 1 100 1` SalesOrder Table ` Order_No Customer_ID (FK) Order_Ref Date 1 1 333 333 2 2 222 222` Produce table ` Prod_No Item_Code(FK) qty Order_No (FK) 10001 1 1 1 10002 2 1 2 ` when select 10001 record from Produce table then it result like `(10001,Pen America,1)` when i select record 10002 then it result like `(10002,Computer,1)` Please suggest...thanks
Что я уже пробовал:
DECLARE @CustID as varchar select * INTO #tmp55 from SalesOrder where CustomerID IN (select CustomerID from CustomerItem) select @CustID = CustomerID from #tmp if @CustID != '' select Customeritem.CIName,Probale.Prdno,ItemMasterFile.BaleSize from CustomerItem inner join ItemMasterFile on ItemMasterFile.Codeitem=CustomerItem.CItem inner join Probale on Probale.Codeitem=ItemMasterFile.CodeItem where Probale.Prdno=1000003 else select Probale.Prdno,ItemMasterFile.BaleSize,ItemMasterFile.BaleSize from ItemMasterFile inner join Probale on Probale.Codeitem=ItemMasterFile.CodeItem where Probale.Prdno=1000003