MySQL Cannot Generate dynamic order number : i cannot generate order numbers using sub query.
here i give sample code which has few tables join.
here i add only main concept others i skipped. so i need to get order number from this query only.

i got correct result but some of the other join tables got Recline(order) is got null after changing the BookHeadId.

 

     select @rhBookHeadId :=rh.BookHeadId ,rd.BookDetailId,@inrec:=0,(select RecLine from (SELECT spodno.BookDetailId, @inrec:= ifnull(@inrec,0)+1, @inrec as RecLine FROM tblBookDetail spodno where spodno.BookHeadId=@rhBookHeadId and spodno.isActive=1 order by spodno.BookDetailId asc ) temp where temp.BookDetailId=rd.BookDetailId) as RecLine from  tblBookHead rh inner join tblBookDetail rh on rh.BookHeadId=rd.BookHeadId inner join ......;
