[sql] fix bug when querying sub-lines