This guys post has a nice explanation of how to use the results from a select statement.

Old Comment by me:

http://www.katcode.com/joomla-database-sql-queries/

Look at number 3.

New Comment: That site was down, but here is the write up.

  1. Getting the default database connection:
    $db =& JFactory::getDBO();
  2. Set the query. Can pass in start and length LIMIT values to shrink the resultset. This will add LIMIT 0,3 to the end.
    $db->setQuery($query,0,3);
  3. Execute the query. You can call various methods depending on what amount of data is being returned

    $db->loadObject() – returns first row as an object. e.g. $obj->field.
    $db->loadObjectList() – returns resultset as an object. For multiple records.
    $db->loadResult() – returns first field of first row as a value. A single value
    $db->loadRow() – returns the first row as an indexed array.
    $db->loadAssoc() - returns first row as an associated array.
    $db->loadAssocList() - returns resultset as an associated array. For multiple records.
    $db->Execute($sql) - Execute sql that doesn't return anything. Pass sql as parameter.
    
    Looping through a resultset:
    $db->setQuery($query,0,3);
    $rows = $db->loadObjectList();
    foreach($rows as $row)
    {
            echo $row->fldname;
    }
    
    This will create a resultset object with specified field as key index value.
    
    
    $db->setQuery("SELECT category_id, name FROM category");
    $categories = $db->loadObjectList('category_id');

I hope this helps someone else out there…