Php Zend Framework:选择重复行
那是我的桌子:Php Zend Framework:选择重复行,php,zend-framework,Php,Zend Framework,那是我的桌子: mat_id| yes| no | type 1 | 1 | 0 | 3 1 | 1 | 0 | 3 2 | 1 | 1 | 3 3 | 1 | 0 | 3 我的选择查询: $q = $db->select()->from('tableName', 'mat_id')->where('type = ?', 3)->group('yes')->having('COUNT(yes) > 1'
mat_id| yes| no | type
1 | 1 | 0 | 3
1 | 1 | 0 | 3
2 | 1 | 1 | 3
3 | 1 | 0 | 3
我的选择查询:
$q = $db->select()->from('tableName', 'mat_id')->where('type = ?', 3)->group('yes')->having('COUNT(yes) > 1');
但是为什么只选择mat\u id=1
,应该选择mat\u id=1,3
?试试这个
$db->select()->->distinct()->from('tableName', 'mat_id')->where('type = ?', 3)->group('yes')->having('COUNT(yes) > 1');
我明白了。你的意思是你想选择另一个专栏吗?很抱歉,这个问题不可理解。你需要弄清楚你想要我们帮助什么。您当前的结果是什么,期望的结果是什么?再次选择only
mat_id=1
您说的仅显示mat_id=1,3。为此,您的条件应该是('type=?and no=?',array(3,0))。因此查询应该是$db->select()->->distinct()->from('tableName',mat id')->where('type=?and no=?',array(3,0))->group(数组('yes','mat_id'))->having('COUNT(yes)>1');我不知道为什么,但再次只选择mat_id=1