由於添加查詢的中間部分(INNER JOIN),查詢現在失敗。我認爲這可能是因爲我在一個表上有兩種類型的連接(charts_extended) - 我看不到從dj_love表獲取所需數據的另一種方式。在MySQL的一個表上使用兩個連接?
SELECT DISTINCT releases . *
FROM releases
INNER JOIN artist_love ON releases.all_artists LIKE CONCAT('%', artist_love.artist, '%')
AND artist_love.user = 'Quickinho'
INNER JOIN label_love ON releases.label_no_country = label_love.label
AND label_love.user = 'Quickinho'
INNER JOIN charts_extended ON charts_extended.release_id = releases.id
WHERE charts_extended.artist
IN (
SELECT dj
FROM dj_love
WHERE user = 'Quickinho'
)
LEFT JOIN charts_extended ON charts_extended.release_id = releases.id
AND charts_extended.artist = 'Quickinho'
WHERE charts_extended.release_id IS NULL
ORDER BY releases.date DESC
要不要再來JOIN - 無需 – Strawberry
在那裏你推薦添加JOIN子查詢? – Franco