Hi all,
I need an help to write a condizional Join from tables. I need to join the table Orders with PrintOrders (list of keys of table Orders) only if PrintOrders is not empty.
I expect 2 different behaviors: when the PrintOrders is empty the query must list all orders of table Orders, when PrintOrders is not empty, the query must list the orders matches with the keys presents in table PrintOrders.
I try to write a conditional join but i have an error that i could not understand:
select * from Orders ORD
if((Select count(*) from PrintOrders) > 0,inner join PrintOrders POR on ORD.NumOrdine=POR.NumOrdine,1=1)
Can anyone help me?
Thanks
Marcello