【问题标题】:Get distinct record from table using zend functions?使用zend函数从表中获取不同的记录?
【发布时间】:2011-08-31 21:40:56
【问题描述】:

我在 Zend 中得到了所有这样的记录:

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

以上代码的结果如下查询:

SELECT `student`.* FROM `student`

现在我想通过邮政编码获取不同的记录。所以查询应该是:

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

我将如何使用 zend 函数进行查询??

谢谢

【问题讨论】:

    标签: mysql zend-framework distinct


    【解决方案1】:

    试试这个

    $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! ='')

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多