Objective

To make a select query in Joomla.

Example (Selecting specific fields from users with condition and sorting)

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('name', 'username', 'email')));
$query->from($db->quoteName('#__users'));
$query->where($db->quoteName('username') . ' LIKE '. $db->quote('%web%'));
$query->order('name ASC');
$db->setQuery($query);
$results = $db->loadObjectList();


See also

Source