As discussed earlier, select statements allow you to retrieve information from the database. There are several methods of doing this in Drupal 7 depending on whether you want to use a procedural or object-oriented syntax and whether or not the SQL statement to be executed is provided by the developer or if the SQL statement is built by Drupal. Let's start by looking at queries where the statement is provided to Drupal.
Static queries use SQL statements that are provided to the DBTNG layer rather than being built by Drupal. For example, to get a list of all nodes in the system, you can call:
<?php $result = db_query("SELECT nid, title FROM {node}"); ?>
This statement simply returns the node ID and title of all nodes within the system.
You may have noticed that the name of the table, in this case node, is surrounded by curly braces. Similar to Drupal 6, you can surround a table with curly braces which causes Drupal to automatically prefix the table...