join with multiple tables
Moderator: General Moderators
join with multiple tables
... or maybe I've got this all wrong in my head. Anyway, I have a query currently that's basically a browse function. It takes the 'results' table (a filtered list of ItemNumbers) and matches it to the 'items' table (which has information on the items) on ItemNumber = ItemNumber. Okay, great. But now I need to join this query as a many-to-one with the 'rebates' table, which also has ItemNumber. But I want to return all results from 'results' regardless of if there's no match on rebates. I know how to do this in two queries but there must be a way to do it in one.
perhaps union is not what you're looking for.
If I understand you correctly, left join would serve better:
If I understand you correctly, left join would serve better:
Code: Select all
select
results.*,
items.*,
rebates.*
from
results
inner join
items
using (ItemNumber)
left join
rebates
using (ItemNumber)