我有這兩個表。我會讓它儘可能簡單:MySQL一對多關係單查詢
Sample value in main_table:
id = 1
Sample value in details_table:
id = 1
type = book
name = harry potter
id = 1
type = paper
name = post it
我需要的結果是獲得ID的名稱爲這兩種類型。
id book paper
1 harry potter post it
這是可能的嗎?
什麼是MAX? – aozora
@aozora這是一個數據透視查詢,'MAX'將保留每個透視列的非NULL值。 –
謝謝,我不知道我在做什麼的正確名詞。現在我知道這是關鍵。 – aozora