开发者

Get distinct record from table using zend functions?

开发者 https://www.devze.com 2023-03-08 11:51 出处:网络
I am getting all records like this in Zend: $table = new Model_Student_Object(); $select = $table->select();

I am getting all records like this in Zend:

$table = new Model_Student_Object();
$select = $table->select();
echo $select->assemble();die();

Result of above code is following query:

SELECT `student`.* FROM `student`

Now I want to get distinct records by Zip code. So query开发者_运维知识库 should be:

SELECT DISTINCT `student`.zip FROM `student` WHERE `student`.zip != '' 

How will I right above query with zend functions ??

Thanks


Try this

    $db = Zend_Db::factory( ...options... );
    $select = new Zend_Db_Select($db);
$select= $db->select()->distinct()->from('s'=>'student'),'zip')->where('practiceID in("1") and s.zip!='')
0

精彩评论

暂无评论...
验证码 换一张
取 消