标题有点令人困惑,希望从我的查询中清楚我想要做什么。我以为我理解联接,显然不是,这是我的 $query:
SELECT DATE(T0.timestamp),
SUM(T0.total_responses),
SUM(T0.responses),
T0.metric_id,
T1.metric_id
FROM `personal_aggregates` AS T0
LEFT JOIN `qrs_metrics` AS T1
ON T0.metric_id = T1.qrs_metric_id
WHERE T0.user_id = 1 AND
T0.duration = '1' AND
T0.category_id IN (1,2,3,4) AND
T0.timestamp >= 'period_duration'
GROUP BY DATE(T0.timestamp)";
我正在尝试加入 metric_id 和 qrs_metric_id 列上的表。但是我没有从上述查询中得到任何结果。当我在 PHP 中遍历结果并检查任何变量时,例如$result['T0.metric_id']
,我得到Undefined index: T0.metric_id
如果有人能对此有所了解,我将不胜感激。