Home    Articles

 

How to use DISTINCT for specific column in Zend Framework database select

 

Here is an example of how you can use DISTINCT statement for a specific column in Zend Framework:

$select = $db->select()
			 ->from('table_name',array('DISTINCT(specific_column)','other_column','other_column'))
		     ->where('column_name =?','value');
# echo $select;
$results = $db->fetchAll( $select );		
# view results of
echo '<pre/>';print_r($results);exit;	

The query will look someting like this:

SELECT DISTINCT(specific_column), `table_name`.`other_column`, `table_name`.`other_column` FROM `table_name` WHERE (column_name ='value')

 

 

by