你好,我有2個表看起來像這樣,左連接mysql的問題
我想的就是讓類別和類別的章節標題中,MySQL是這樣的,
SELECT `categories`.`category_id`,
`categories`.`category_title`,
`categories`.`category_created`,
`section`.`section_id`,
`section`.`section_title`,
`categories`.`parent_section`
FROM (`categories`)
LEFT JOIN `section`
ON `section`.`section_id` = `categories`.`category_id`
但是,我回來的是類別和部分的列表,而不是類別列表和它們的父部分。我做錯了什麼?
我敢打賭,你的意思是JOIN ON 'section'.'section_id''' categories'.'parent_section_id' – Andrew 2012-02-17 15:44:47
啊廢話!知道這將是愚蠢的! – Udders 2012-02-17 15:45:26
什麼是parent_section,一個自引用? 「分類」是一棵樹嗎?在這種情況下,您是否需要取回父母? – 2012-02-17 15:45:39