I am trying to run a query on a SQLite database that INNER JOINs two additional tables:
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)
However, I get the error
SQL error: cannot join using column item_id - column not present in both tables
I know I can use the explicit INNER JOIN stores ON usages.store_id = stores.store_id (and it works), but:
why does the USING query throw an error in SQLite?
It doesn’t on MySQL…
I should note:
This isn’t a problem for me, as I am using the ON syntax, but I would like to know why this is happening.
So you have:
…and you get an error that says:
That’s got to be one of the least cryptic error messages I’ve seen.
What I don’t like is that it’s not clear to me what table is being compared to
ITEMS.item_id– is itSTORESorUSAGES? Which is why I refrain from theUSINGorNATURALjoin syntax…