我試圖通過流派和主要流派的描述提供所有樂隊的概述。

最終結果應該像第二張圖片

這是我的查詢,
select m.name, m.genretitle, g.description
from music band as m, genre as g
where m.genretitle = g.title and g.genre title_main genre
in
(
select title
from genre
);
但是后來我得到了錯誤的輸出。請問我在這里做錯了什么?
謝謝你
uj5u.com熱心網友回復:
你應該在標題/流派(錯別字?)
# MySql syntax
SELECT m.name, m.genre_title, g.description
FROM music_bands m
JOIN genre g ON g.title = m.genretitel
uj5u.com熱心網友回復:
另一個左加入流派應該這樣做。
SELECT
band.name AS `Band`
, band.genre_title AS `Genre`
, main.description AS `Main genre description`
FROM music_bands AS band
JOIN genre
ON genre.title = band.genretitle
LEFT JOIN genre AS main
ON main.genre = genre.`genre title_main genre`
AND main.`genre title_main genre` IS NULL
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/363531.html
標籤:sql
上一篇:根據表B中的日期范圍透視一個欄位,即>=表A中的日期范圍
下一篇:如何根據處理順序更新日期列?
