Connecting points with line in a specific sequence

Solution with algorithms and expressions

For the fist part of your problem :

You could use the geometry by expression algorithm and use this expression :

collect_geometries(
    array_foreach(
        aggregate( 
            'LAYERNAME' ,
            'array_agg', 
            "mrid", 
            filter:="id" =  attribute(@parent, 'id')+1),
        make_line($geometry, geometry(get_feature('LAYERNAME', 'mrid',@element)))
    )
)

It's not the best approach to what mentioned Kadir. If there are 2 ore more children this expression will build a multilinestring.

For the second part, apply the multiparttosinglepart algorithm on the output of the first treatment. The mrid field correponds to the start and you can obtain the end by adding a new fied on the ouput with this formula :

aggregate('LAYERNAME',
'concatenate', "mrid", filter:= intersects($geometry,end_point(geometry(@parent)))) 

*intersects is used in place of equals

** LAYERNAME is the SOURCE LAYER (point layer)


All in one solution with virtual layer

For your probleme you can indeed use virtual layer, I didn't know you want use this method :

with
build_segment as (
select 
  a.mrid as start_point, 
  b.mrid as end_point,
  makeline(a.geometry, b.geometry) as geometry
from <layername> a
left join <layername> b on (a.id + 1 = b.id  ))

select
  * 
from build_segment
where geometry is not null