我正在尝试在SQLite数据库上运行一个查询,该查询使用INNER JOIN
连接了另外两个表:
SELECT
usages.date AS date,
usages.data AS data,
stores.number AS store,
items.name AS item
FROM usages
INNER JOIN stores USING (store_id)
INNER JOIN items USING (item_id)
然而,我遇到了错误。
SQL error: cannot join using column item_id - column not present in both tables
我知道我可以使用明确的
INNER JOIN stores ON usages.store_id = stores.store_id
(它可以工作),但是:为什么USING
查询在SQLite中会出错? 在MySQL上不会出现这种情况...我应该注意:
这对我来说不是问题,因为我正在使用
ON
语法,但我想知道为什么会发生这种情况。
INNER JOIN stores ON usages.store_id = stores.store_id
是可行的,但是错误信息并不是关于这个连接的。 - Martin SmithON
语法可以工作,但USING
语法不行。 - Austin Hyde