Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Avinash8385
Starting Member
1 Post |
Posted - 2008-07-16 : 03:30:52
|
Hi..! Everyone..!! I need to check more than one value in like keyword as i used below also want to retrieve data from database kindly help me..select mb.mrno,mb.prodid,d.deptname,mb.invqty,mb.rate,case when (mb.accqty is null) then 0 else mb.accqty end as AccQty,(mb.invqty-(case when (mb.accqty is null) then 0 else mb.accqty end)) as rejQty from tblMatreceipt_Body mb,tblMatreceipt_head mh,tblDept d where mb.prodid like +(select deptprefix from tblDept where deptid in (1002,1003,1004))+'%' and mb.mrno=mh.mrno and mh.Mrdate>='7/12/2008' and mh.mrdate<='7/15/2008' and d.deptid in (1002) But i can able to retrieve the data from the database if i provide only one value in deptid as shown below..select mb.mrno,mb.prodid,d.deptname,mb.invqty,mb.rate,case when (mb.accqty is null) then 0 else mb.accqty end as AccQty,(mb.invqty-(case when (mb.accqty is null) then 0 else mb.accqty end)) as rejQty from tblMatreceipt_Body mb,tblMatreceipt_head mh,tblDept d where mb.prodid like +(select deptprefix from tblDept where deptid in (1002))+'%' and mb.mrno=mh.mrno and mh.Mrdate>='7/12/2008' and mh.mrdate<='7/15/2008' and d.deptid in (1002) Thanks In Advance... |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-16 : 06:59:12
|
join with query required on like condition. also try to use ANSI join syntax.select mb.mrno,mb.prodid,d.deptname,mb.invqty,mb.rate,case when (mb.accqty is null) then 0 else mb.accqty end as AccQty,(mb.invqty-(case when (mb.accqty is null) then 0 else mb.accqty end)) as rejQty from tblMatreceipt_Body mbjoin tblMatreceipt_head mhon mb.mrno=mh.mrno join (select deptprefix,deptid from tblDept where deptid in (1002,..)) don mb.prodid like t.deptprefix +'%' where mh.Mrdate>='7/12/2008' and mh.mrdate<='7/15/2008' and d.deptid in (1002) |
 |
|
|
|
|
|
|