in reply to Reading A TAble

The way of fetching data you demonstrated is nearly as fast and effective as possible :) I don't think it needs any improvements in your case, as you want to extract all data matching your criteria.

Of course, if you want to fetch only a certain number of rows, you can use the LIMIT modifier in your SELECT statements. See Mysql Documentation.

Replies are listed 'Best First'.
Re^2: Reading A TAble
by PerceptiveJohn (Acolyte) on Jul 12, 2006 at 19:58 UTC
    Ok, but doesn't this method take a lot of memory??

    And, do you know the syntax of the select command to read by primary key or another index key? Thanx.

      Just let MySQL do its work :) The memory management for each request isn't your task, it's the task of database engine.

      the syntax of the select command to read by primary key or another index key?
      I did not understand your question. Maybe you want to get the data corresponding to a key? In this case you need to specify the WHERE clause to read only certain data from the table, e.g.

      SELECT id, name FROM mytable WHERE id=1
      I repeat: RTFM! MySQL documentation contains the full info on SQL syntax. 10 minutes of reading the docs will save for you hours of asking questions :)
      Accessing the table in the method you described should not load the whole table into memory. If you'd like to order the results by some field (primary key or otherwise), use an ORDER BY clause in your select statement.