Select products with users
- by Ploppe
I have not worked with SQL for quite a long time, and I need some help for a basic query. I have the three following tables:
users (id, name)
products (id, name)
owners (userid, productid, date)
One product can be sold by user A to user B and then back to A.
Now, I want the list of all products currently owned by every single user with the date of transaction.
Currently, my query is this one, but I'm stuck with old data (first association of one product to one user, and not the newest one):
SELECT users.name, products.name, date
FROM products
JOIN owners ON products.id = owners.id
JOIN users ON owners.id = user.id
GROUP BY product.id
Do you have some hints?
Thanks