我已经获得了以下不会工作的代码' ...如何从SQL查询中排除多个项目?我没有运气就试过很多不同的组合:(
$this->autoLayout = false;
$this->set('songs', $this->CcFile->find('all', array(
'fields' => array(
'track_title',
'artist_name',
'lptime',
'id'
),
'conditions' => array(
'AND' => array(
'NOT' => array(
'artist_name' => 'Jam FM Bed',
),
'NOT' => array(
'artist_name' => 'Airtime Show Recorder',
),
'NOT' => array(
'artist_name' => 'Jam FM Jingles',
),
'NOT' => array(
'artist_name' => 'Kent Scout Jingles',
),
),
),
'order' => array(
'lptime' => 'desc nulls last',
'artist_name' => 'asc'
)
)));
答案 0 :(得分:4)
试试:
'NOT' => array(
'artist_name' => array(
'Jam FM Bed',
'Airtime Show Recorder',
// ...
)
)
或
'artist_name NOT IN' => array(
'Jam FM Bed',
'Airtime Show Recorder',
// ...
)
答案 1 :(得分:0)
试试这个
修正代码
$this->autoLayout = false;
$this->set('songs', $this->CcFile->find('all', array(
'fields' => array(
'track_title',
'artist_name',
'lptime',
'id'
),
'conditions' => array(
'NOT' => array(
'artist_name' => Array(
'Jam FM Bed',
'Airtime Show Recorder',
'Jam FM Jingles',
'Kent Scout Jingles')
),
),
'order' => array(
'lptime' => 'desc nulls last',
'artist_name' => 'asc'
)
)));