title: select limit in sql
body: <p>I wrote this query but gives me an error at line 15 (limit clause).
  we have 3 tables, state, email, and receiver.</p>
  
  <pre><code>CREATE PROCEDURE `inbox`(IN `page_size` INT,IN `page_number` INT)
  BEGIN
      set @curr = ( SELECT entered_accounts.username
                  FROM entered_accounts
                  WHERE entered_accounts.time = (SELECT Max(entered_accounts.time) FROM entered_accounts));
      SET @tmp = page_number-1;
      SET @offset = page_size * @tmp;
  
      SELECT email.subject, email.body, email.time, state.readed, state.deleted
      FROM email INNER JOIN reciever USING(email_id) 
                  INNER JOIN state USING (email_id) 
      WHERE state.username=reciever.username AND LOWER(reciever.username)=LOWER(@curr) AND NOT reciever.username=email.username
      ORDER BY email.time DESC
      LIMIT @offset,page_size;
  END
  </code></pre>