0
我試圖做一個數據庫查詢包括與yii2先進的框架聯接Yii2查詢 - 加入MySQL查詢中出現兩次
$query = new \yii\db\Query;
$res = $query->select('date')->from(Heartbeat::tableName())
->join('INNER JOIN', Client::tableName(), 'id = client_id')
->where(['name' => $client])
->orderBy('date DESC')->limit(1)->scalar();
正在執行的SQL(V2.0.4)是:
SELECT `date` FROM `heartbeat`
INNER JOIN `client` ON id = client_id
INNER JOIN `client` ON id = client_id
WHERE `name`='CLIENT01' ORDER
BY `date` DESC LIMIT 1
我的代碼有什麼問題? 爲什麼連接出現兩次?