I tried with this query but no luck :
SELECT tr.transferfrom, tr.transferto, br.id as 'BR_ID',
tr.refno, br.name as 'BR_NAME', br.code as 'BRANCH_CODE',
tr.docno, tr.transdate, stk.stockno,stk.salescat,tr.qty,
tr.sprice,tr.qty*tr.sprice as 'GROSS_SALES'
FROM TRANSFER tr
JOIN branch br on tr.branchid=br.id
JOIN stocks stk on tr.stockid=stk.id
WHERE (tr.docno = 'ST00576' AND br.id IN ('*'))
OR RIGHT(tr.refno,7) = 'ST00576' AND LEFT(tr.refno,3) IN ('*')
I wanted to have query to select ALL records if the br.id is a blank value.
Have a subquery that gets all the branch ids and then the
INquery can refer to the output of the subquery.. the subquery will be likeselect br.id from branch brThus the entire query will look like: