我正在使用以下 zend 代码从 verified=1 的表中选择所有数据,它对我有用。
$table = $this->getDbTable();
$select = $table->select();
$select->where('verified = 1');
$rows = $table->fetchAll($select);
不,我想从该表中选择所有已验证不等于“1”的数据。我尝试了以下方法,但它没有获取数据。
$select->where('verified != 1');
$select->where('verified <> 1');
$select->where('verified != ?', 1);
“已验证”列的数据结构:
Field: verified
type: varchar(45)
Collation: utf8_bin
NULL: Yes
Default: NULL
知道如何在 Zend 的 WHERE 子句中使用“不等于”运算符吗?谢谢
最佳答案
$select->where('verified != ?', 1);
现实世界的查询示例:
$query = $this->getDb()->select();
$query->from('title', array('title_id' => 'id', 'title', 'production_year', 'phonetic_code'))
->where('kind_id = 1')
->where('title = ?', trim($title))
->where('production_year != ?', '2009')
->limit(1)
;
从 IMDB 数据库中选择电影信息。工作正常。
关于zend-framework - 发送 : How to use 'not equal to' in WHERE clause?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1932431/