我有兩張表,歌曲和歷史記錄。歌曲表如下所示:PHP MySQL加入兩張表
ID | title | artist | duration
1 | some title | some artist | 83592
歷史表看起來像:
ID | title | artist | duration | date_played
5 | some title | some artist | 83592 | 2012-08-08 11:22:00
我怎麼會從歌曲表呼應ID,如果從歷史上最新的條目標題和藝術家表匹配?
我試過SELECT * FROM history JOIN songs ON title=songs.title AND artist=songs.artist ORDER BY date_played DESC LIMIT 0, 1
,但沒有奏效。有任何想法嗎?
謝謝!我會接受它作爲答案,當它讓我! – austinhollis 2012-08-14 17:03:24