views:

55

answers:

1

HERE IS A QUERY

select IssueNo, KendraCode, IssueTime, DateOfIssue, P_MotaBags, P_MotaWeight, P_PatlaBags, P_PatlaWeight, P_SarnaBags, P_SarnaWeight, NewBags,OldBags, TransporterName, TruckNumber, DriverName, TruckOwner,SocietyCode 
,
(SELECT PaddyMotaW, PaddyPatlaW, PaddySarnaW, BagsMota, BagsPatla, BagsSarna,PC_ID, sangrahankendraid, SocietyCode,DM_ID FROM ReceiveFromSociety WHERE DM_ID=S.IssueNo)
from IssueToSangrahanKendra_Soc S
where KendraCode='4403' order by SocietyCode  

Where is the problem

+4  A: 

You cannot select multiple fields in a subselect like that, only 1 filed will be permitted.

Also, formmating the code will make it a lot easier to read in the future.

Try the following

select  IssueNo, 
        KendraCode, 
        IssueTime, 
        DateOfIssue, 
        P_MotaBags, 
        P_MotaWeight, 
        P_PatlaBags, 
        P_PatlaWeight, 
        P_SarnaBags, 
        P_SarnaWeight, 
        NewBags,
        OldBags, 
        TransporterName, 
        TruckNumber, 
        DriverName, 
        TruckOwner,
        SocietyCode, 
        rfs.*
from    IssueToSangrahanKendra_Soc S LEFT JOIN
        (   SELECT  PaddyMotaW, 
                    PaddyPatlaW, 
                    PaddySarnaW, 
                    BagsMota, 
                    BagsPatla, 
                    BagsSarna,
                    PC_ID, 
                    sangrahankendraid, 
                    SocietyCode,
                    DM_ID 
            FROM    ReceiveFromSociety 
        ) rfs ON rfs.DM_ID =S.IssueNo
where   KendraCode='4403' 
order by    SocietyCode 
astander
Thanks and sorry for not formatting the code :)
Akshay