SELECT *
FROM transaction
INNER JOIN user ON (transaction.transactionuser = user.userid)
This will return all fields from both tables and will use transactionuser and userid to match the rows. In other words: how do I glue the rows and what data I present.
So the above query will output all transactions for all users that exist in both tables. So if there is a transaction without user it will not output it.
If a transaction row has a transactionuser that doesn’t have a match userid in the user table it will not output it the row as there is no intersection.
LEFT JOIN will output all rows from the left join even if there is no match on the right table.
RIGHT JOIN will do the contrary. Output all rows from the right table even if there is no march on the left table.
Once that is clear then you use the WHERE clause to add filters or conditions. Like for example filter by one user, by dates, by amounts, etc
If you want to show only transactions for user “123” and all the info associated from both tables you would do.
SELECT *
FROM transaction
INNER JOIN user ON (transaction.transactionuser = user.userid)
WHERE transaction.transactionuser = ‘123’