I Have 2 tables with this info
tabsell
SellId | ItemId
1 | 2
2 | 3
3 | 2
4 | 3
5 | 4
tabitens (this table have alot of columns but i put only 2 for a example)
ItenId | ItemName
2 | Iten2
3 | Iten3
4 | Iten4
5 | Iten5
What im try to do is
Select FROM tabitens only if the SUM of the ItenId on tabsell is < 2
What is the right way to make the query?
Thanks!
you need to use
LEFT JOINon this soItemswith no records (not been sold) on tableSell will also be shown on the list.COUNTis recommended to use thanSUMbecauseCOUNTadds the number of rows whileSUMadds the value of rows.