The result of a query is a set of 0 or more rows. If you are using an ODBC driver or JDBC driver, you retrieve each row by using the appropriate ODBC or JDBC functions.
As a general rule, you go through the following steps
1 Prepare the SQL statement. During the prepare phase, the server analyzes the statement and (among other things) looks to see how many parameters there will be. The number and meaning of the parameters is shown by the question marks that are included in the SQL statement.
2 Tell the ODBC driver which variables will be used as parameters. Telling the ODBC driver which variable is associated with which column or value is called "binding" the parameters.
3 Execute the prepared statement. This tells the server to execute the query and collect the result set. However, the result set is not passed to the client immediately.
4 Fetch the next row of the result set. When you do a fetch, you tell the server and the ODBC driver to retrieve one row of results from the result set and then store the values of that row into the parameters that you previously defined for the ODBC driver to share with your application.
Normally you will perform a loop, fetching one row at a time and reading the data from the parameters after each fetch.