SELECT DISTINCT `timeline_id` , `status_id`
FROM `timeline`,`status`
Where `timeline`.`user_id` = 1
ORDER BY `timeline`.`dates` DESC
输出
timeline_id status_id
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
答案 0 :(得分:0)
如果您在tbl status
中有字段user_id,请尝试以下操作:
SELECT DISTINCT `timeline_id` , `status_id`
FROM `timeline` LEFT JOIN`status`
ON `timeline`.user_id = `status`.user_id
Where `timeline`.`user_id` = 1
ORDER BY `timeline`.`dates` DESC