我有兩個表ad_pool和廣告。 ad_pool有一些數據,而廣告是空的。我使用這段代碼從第一個表中選擇不等於這個和這個(''','fisttablekey','second_tbl_key'])的查詢。這是我用來檢索數據的完整代碼,我也上傳了圖像。
$pool1 = (new Query())>select('p.id,p.cleaner_user_id,p.ad_place_id')
->from('ad_pool p')
->innerJoin('advertisment a' , 'p.id = a.pool_id')
->where(['=','ad_place_id',1])
->andWhere(['<>','p.id','a.pool_id'])
->orderBy(new Expression('rand()'))
// ->limit(1)
->all();
var_dump($pool1);
exit();
這回我空數組。需要你的幫助。提前致謝。
用'createCommand() - > rawSql'替換'all()'並在數據庫控制檯中運行它的輸出以查看是否得到任何結果。 – Bizley
它給了我這個錯誤...語法錯誤,意外的'返回'(T_RETURN) –