Curiosity - PHP and Data Query Limit

1

Today while doing a query by type PhpMyAdmin SELECT * FROM tabela , I noticed that after a query in the database the query automatically gets the LIMIT , in this way SELECT * FROM tabela LIMIT 0 , 30 , that is, if I am correct, it starts with the first record and it shows 30 results. That intrigued me, because in PHP I do these querys and send everything to a table, but what if for a year I make more than 100 entries and want to see them all? I can never foresee the limit of it. In php I thought I would use a variable for the limit, which received COUNT of all records in the table, or make a subquery of type SELECT * FROM TABELA LIMIT (SELECT COUNT(*) FROM TABELA) . I just look for methods that might help in the future.

    
asked by anonymous 05.05.2016 / 21:42

1 answer

0
  

My question is, basically, if it were you on a site that you   what you would do to display more than 100 data on a table.   Knowing that, you would not know how many lines of information the base   of data had, just knew that I wanted to see them all

I believe that now I understand your question.

No, LIMIT is not required in a query. You should only use it when you really want to restrict the number of records that the query should return, to a certain number, instead of displaying all. If you have a table with an indeterminate number of records, and you want to show all the rows, you do not need to place the LIMIT clause in the query. Ex:

SELECT * FROM tabela

Get all the data in the table.

What PhpMyAdmin does, is to add a LIMIT of 30 in the query, to avoid over-listing of data, and thus not to compromise the performance of the tool ...

I recommend taking a look: link

    
05.05.2016 / 22:20