0
mysql_query(conn,"SELECT abstract FROM papers limit 4 ");

Can we use variables in limit function in C-api.Like I have to iteratively extract 10 rows,so something of the form: mysql_query(conn,"SELECT abstract FROM papers limit $i $i+10 ");

akshita007
  • 549
  • 1
  • 9
  • 15
  • 1
    Possible duplicate of [Variable LIMIT Clause in MySQL](http://stackoverflow.com/questions/245180/variable-limit-clause-in-mysql) – Breeze Apr 30 '16 at 21:40

2 Answers2

0

what you seek is "OFFSET"

e.g. SELECT abstract FROM papers LIMIT 10 OFFSET 20 gives 10 results (skipping over the first 20)

Ref: http://dev.mysql.com/doc/refman/5.7/en/select.html

0

I solved the above issue by using strings. strcpy(query,"SELECT abstract from PAPERS limit "); pos=0; sprintf(temp,"%d %d",pos,pos+100); strcat(query,temp);

In this way pos can also be used as iterator.

akshita007
  • 549
  • 1
  • 9
  • 15