您是否可以在内部联接表上使用where约束来限制结果?

时间:2017-12-27 05:13:31

标签: python sqlite

解决

sql = "SELECT Title, Year, TmdbId, MovieFileId, Quality " \
      "FROM Movies " \
      "INNER JOIN MovieFiles on MovieFiles.Id = Movies.MovieFileId " \
      "WHERE Quality = 7"

sql = "SELECT Title, Year, TmdbId, MovieFileId, MovieFiles.Quality " \
      "FROM Movies " \
      "INNER JOIN MovieFiles on MovieFiles.Id = Movies.MovieFileId " \
      "WHERE MovieFiles.Quality = 7"

这些都不适合我,我没有返回任何行。质量是MovieFiles表的一部分。是的,存在符合此标准的行。

sql = "SELECT Title, Year, TmdbId, MovieFileId, Quality " \
      "FROM Movies " \
      "INNER JOIN MovieFiles on MovieFiles.Id = Movies.MovieFileId "

这很好用,并返回正确的质量。但是,如果我添加where,它不起作用,只返回任何内容。难道我做错了什么? (使用python)

编辑:架构请求

CREATE TABLE "Movies" ("Id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "ImdbId" TEXT, "Title" TEXT NOT NULL, "TitleSlug" TEXT NOT NULL, "SortTitle" TEXT, "CleanTitle" TEXT NOT NULL, "Status" INTEGER NOT NULL, "Overview" TEXT, "Images" TEXT NOT NULL, "Path" TEXT NOT NULL, "Monitored" INTEGER NOT NULL, "ProfileId" INTEGER NOT NULL, "LastInfoSync" DATETIME, "LastDiskSync" DATETIME, "Runtime" INTEGER NOT NULL, "InCinemas" DATETIME, "Year" INTEGER, "Added" DATETIME, "Actors" TEXT, "Ratings" TEXT, "Genres" TEXT, "Tags" TEXT, "Certification" TEXT, "AddOptions" TEXT, "MovieFileId" INTEGER NOT NULL, "TmdbId" INTEGER NOT NULL, "Website" TEXT, "PhysicalRelease" DATETIME, "YouTubeTrailerId" TEXT, "Studio" TEXT, "MinimumAvailability" INTEGER NOT NULL, "HasPreDBEntry" INTEGER NOT NULL, "PathState" INTEGER NOT NULL, "PhysicalReleaseNote" TEXT, "SecondaryYear" INTEGER, "SecondaryYearSourceId" INTEGER)

CREATE TABLE "MovieFiles" ("Id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "MovieId" INTEGER NOT NULL, "Path" TEXT, "Quality" TEXT NOT NULL, "Size" INTEGER NOT NULL, "DateAdded" DATETIME NOT NULL, "SceneName" TEXT, "MediaInfo" TEXT, "ReleaseGroup" TEXT, "RelativePath" TEXT, "Edition" TEXT)

0 个答案:

没有答案