在我的網站上,我有一種方法,允許登錄用戶將文章標記爲收藏夾,登錄時文章突出顯示爲保存爲收藏夾,但如果用戶沒有收藏夾,我無法讓查詢返回任何數據,我的查詢出了什麼問題?mysql幫助...故障重現數據
SELECT `job_id`,
COUNT(jobs.job_id) as jobs,
`employers`.`employer_id`,
`logo_small`, `logo_large`,
`company_name`, `job_tags`,
`favourite_employers`.`employer_id` AS employer
FROM (`employers`)
LEFT JOIN `jobs` ON `employers`.`employer_id` = `jobs`.`employer_id`
JOIN `favourite_employers` ON `favourite_employers`.`employer_id` = `jobs`.`employer_id`
WHERE `favourite_employers`.`user_id` = '2'
GROUP BY `jobs`.`employer_id`
ORDER BY `jobs`.`job_id` DESC
任何錯誤消息? – Neal
等待,如果用戶沒有收藏夾,並且您在查詢用戶的收藏夾,那麼您是不是期望沒有返回......? – Dirk
@dirk,我是否必須先運行另一個查詢來查看他們是否首先有收藏? – Udders