Search code examples
mysqlselectlimitinformation-schema

Use of Limit in mysql


enter image description here

First query is giving fine results but question is about 2nd

When I have given limit 2,2. How two rows can be selected? this is the weied beahaviour query

SELECT Ordinal_Position, Column_Name FROM information_schema.columns WHERE
table_schema = 'accounts' AND table_name = 'chequeout' LIMIT 2 , 2

What is wrong with 2nd query or its sum bug? What could be the solution?

Expected result of second query is a single row with values 2 and Amount


Solution

  • You're probably a little confused about how to use LIMIT:

    LIMIT <offset>,<limit>
    

    <offset> means starting row index and <limit> tells how much rows.