Curiosity - PHP and Data Query Limit

Asked

Viewed 653 times

1

Today while doing an appointment by Phpmyadmin of the type SELECT * FROM tabela , I noticed that after making a query in the database automatically the query gets the LIMIT, in this way SELECT * FROM tabela LIMIT 0 , 30, that is if I’m correct, it starts with the first record and shows 30 results. That intrigued me, because in PHP I make 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 predict the limit of it. In php I thought to use a variable for the limit, which received the COUNT of all table records, or make a subquery of the type SELECT * FROM TABELA LIMIT (SELECT COUNT(*) FROM TABELA). I’m just looking for methods that might help in the future.

  • I guess that’s it PHP script paging

  • 1

    In fact I still don’t understand what your doubt is. It seems that you are simply making statements. Yes, Phpmyadmin limits the data, but if you determine the "limit" in the query, this is changed. Yes, if you enter 100 data you will see only 30 (if you just click on the table) of Phpmyadmin, but nothing that prevents you from using the LIMIT specific in your query.

  • Also did not understand the doubt. From what I understand you are using a standard Phpmyadmin web query.

  • My question is, basically, if it were you on a website that you did, what would you do to expose in a table more than 100 data. Knowing that, you wouldn’t

1 answer

0


My question is, basically, if it were you on a website that you did, what would you do to expose in a table more than 100 data. Knowing that, you would not know how many information lines the basis I just knew I wanted to see them all

I believe I now 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 the query should return to a given number instead of showing them all. If you have a table with an undetermined number of records, and you want to display the rows, just don’t put the LIMIT clause in the query. Ex:

SELECT * FROM tabela

Fetch all table data.

What Phpmyadmin does, is to add a LIMIT of 30 in the query, to avoid the overlisting of data, and thus not compromise the performance of the tool...

I recommend taking a look: http://www.w3schools.com/php/php_mysql_select_limit.asp

  • enlightened, thank you :) I thought that if I did not put LIMIT, he put alone anyway

Browser other questions tagged

You are not signed in. Login or sign up in order to post.