下面的图片是我的示例数据库,我想查询与date_received
和date_released
与time_received
不同的time_released
。
以下MySQL查询完全可以满足我的要求:
SELECT * FROM `dts_track` where date_received != date_released and time_received != time_released
到目前为止,这是我的Yii2活动记录查询,但它会从数据库返回所有记录:
$unit_received = \common\models\dts\DtsTrack::find()->where(['!=', 'dts_track.date_received', 'dts_track.date_released'])->andWhere(['!=', 'dts_track.time_received', 'dts_track.time_released']);