Can not sort column bcoz of using joins on two table and i am using server side processing c#

Can not sort column bcoz of using joins on two table and i am using server side processing c#

sid23sid23 Posts: 1Questions: 1Answers: 0

select @i:=@i+1 AS RowNum,A.ReceiptNo as ReceiptNo,DATE_FORMAT(A.ReceiptDate,'%d-%m-%y') as ReceiptDate,G.Name as Guest,R.Name as Room,A.Amount
from advancereceipt A
LEFT JOIN guestmaster G
ON A.Guest = G.Code
LEFT JOIN roommaster R
ON A.Room = R.Code,
(SELECT @i:=0) AS foo
where (Search IS NULL
Or A.ReceiptNo like CONCAT('%' , Search , '%')
Or DATE_FORMAT(A.ReceiptDate,'%d-%m-%y') like CONCAT('%' , Search , '%')
Or G.Name like CONCAT('%' , Search , '%')
Or R.Name like CONCAT('%' , Search , '%')
Or A.Amount like CONCAT('%' , Search , '%'))
order by
case
when SortDir <> 'ASC' then ''
when SortCol = '1' then A.ReceiptNo
end ASC,
case
when SortDir <> 'DESC' then ''
when SortCol = '1' then A.ReceiptNo
end DESC,
case
when SortDir <> 'ASC' then ''
when SortCol = '2' then A.ReceiptDate
end ASC,
case
when SortDir <> 'DESC' then ''
when SortCol = '2' then A.ReceiptDate
end DESC,
case
when SortDir <> 'ASC' then ''
when SortCol = '3' then G.Name
end ASC,
case
when SortDir <> 'DESC' then ''
when SortCol = '3' then G.Name
end DESC,
case
when SortDir <> 'ASC' then ''
when SortCol = '4' then R.Name
end ASC,
case
when SortDir <> 'DESC' then ''
when SortCol = '4' then R.Name
end DESC ,
case
when SortDir <> 'ASC' then 0
when SortCol = '5' then A.Amount
end ASC,
case
when SortDir <> 'DESC' then 0
when SortCol = '5' then A.Amount
end DESC
);

This discussion has been closed.