我有这样的数据库查询,在MySQL中运行良好:
select authors.name, authors.surname, books.name, publishers.name, copies.comment
from authors, books, publishers, copies
where (authors.id, books.id) in (select authorship.author_id, authorship.book_id from authorship)
and (books.id, publishers.id, copies.publish_id) in (select publishment.book_id, publishment.publisher_id, publishment.id from publishment);
在SQLite数据库中,我在“where(authors.id,books.id)in”中遇到了这样的错误:
Error: near ",": syntax error
是否可以在SQLite中进行这种类型的查询(可能 - 使用不同的语法)?
PS:我知道使用连接对于这些情况更好,但我想知道是否可以获得一般知识。
答案 0 :(得分:1)
我知道使用连接对于这些情况更好,但我想知道是否可以获得一般知识。
不,这是不可能的。使用显式连接。
SELECT
a.name, a.surname, b.name, p.name, c.comment
FROM
authors a
INNER JOIN authorship ab ON ab.author_id = a.id
INNER JOIN books b ON b.id = ab.book_id
INNER JOIN publishment p ON p.book_id = b.book_id
INNER JOIN copies c ON c.publish_id = p.id
(顺便说一句,你应该为mySQL做同样的事情)