sql - Inner join query -


please go thourgh attached image descirbed scenario:

i want sql join query.enter image description here

have @ like

select  *    orders o       exists  (                     select  1                        orderbooks ob inner join                             books b on  ob.bookid = b.bookid                       o.orderid = ob.orderid                     ,     b.isbook = @isbook                 ) 

the query return orders based on given criteria.

so, is, when @isbook = 1 return orders there exists 1 or more entries linked order books. , if @isbook = 0 return orders there exists 1 or more entries linked order not books.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -