我正在綁定幾個表到一個腳本。要做到這一點,我意識到我需要使用INNER JOIN,這讓我感到困惑。SQLite腳本從多個表中選擇
"SELECT UserSpecies.commonName, UserSpecies.commonNameFR, UserSpecies.commonNameES, UserSpecies.commonNameDE, UserSpecies.speciesName, UserSpecies.speciesRegion, UserSpecies.speciesDetails, UserSpecies.maxSize, UserSpecies.creditSource, UserSpecies.UserCreated, UserSpecies.genusUC, UserSpecies.familyUC, UserSpecies.orderUC, UserSpecies.groupUC, UserSpecies.subGroupUC, UserSpecies.authority, Genus.name, Family.name, Orders.name, Groups.name, SubGroups.name, Types.name, IUCN.name
FROM UserSpecies
INNER JOIN Genus ON UserSpecies.genusKey = Genus.id
INNER JOIN Family ON UserSpecies.familyKey = Family.id
INNER JOIN Orders ON UserSpecies.orderKey = Orders.id
INNER JOIN Groups ON UserSpecies.groupKey = Groups.id
INNER JOIN SubGroups ON UserSpecies.subGroupKey = SubGroups.id
INNER JOIN Types ON UserSpecies.typeKey = Types.id
INNER JOIN IUCN ON UserSpecies.iucnKey = IUCN.id
WHERE UserSpecies.id = %d"
當我運行上述,我沒有得到任何錯誤,但它根本不檢索數據。
注意:所有表和列都是正確的。
我缺少什麼?
你是否使用python?嘗試在具有特定ID的sqlite控制檯中執行此操作。 –
請提供一些示例數據和您所需的輸出。 (參見[堆棧溢出 後如何 格式SQL表?](https://meta.stackexchange.com/q/96125)如何增加一些。) –