How the value of the initial value starts from another table in mysql

I have a query for sql query, I want to use the launch restriction index from another table. How can i do this?

  SELECT std.totalmarks 
    FROM student as std  
   WHERE std.status=1 
ORDER BY (std.datetime) ASC 
   LIMIT ( 
          SELECT us.startnum 
            FROM user AS us 
           WHERE us.username='abc'
          ),10
+3
source share
2 answers
select q.totalmarks from
(
SELECT *,@curRow := @curRow + 1 AS row_number
FROM student as std JOIN    (SELECT @curRow := 0) r
WHERE std.status=1
ORDER BY (std.datetime) ASC
) q
where row_number>( 
          SELECT us.startnum 
            FROM user AS us 
           WHERE us.username='abc'
          )
limit 10
+2
source
select * from
   (SELECT std.totalmarks, numstart.startnum, @n:=@n+1 as number 
    FROM student as std,
         (SELECT us.startnum 
            FROM user AS us 
           WHERE us.username='abc') as numstart,
         (SELECT @n:=0) sess_var
    WHERE std.status=1 
    ORDER BY (std.datetime) ASC) res
where number>=startnum 
LIMIT 0,10
+2
source

All Articles